Commit db4f24d11d7a7688142cd3730b2432118177c55d
1 parent
f60f0bd9
Exists in
master
and in
110 other branches
redmine #5385, #4786, + #5722 (not finished)
Showing
4 changed files
with
291 additions
and
794 deletions
Show diff stats
js/app/AmdaApp.js
... | ... | @@ -475,12 +475,11 @@ Ext.define('amdaApp.AmdaApp', { |
475 | 475 | { |
476 | 476 | // SUCCESS |
477 | 477 | var msg = '<b>Login :</b> '+result['login']+'<br/>'; |
478 | - msg += ('<b>Last Name :</b> '+result['name']+'<br/>'); | |
479 | - msg += ('<b>First Name :</b> '+result['first_name']+'<br/>'); | |
478 | + msg += ('<b> Name :</b> '+result['first_name']+' '+result['name']+'<br/>'); | |
480 | 479 | msg += ('<b>Groups :</b> '+result['group']+'<br/>'); |
481 | 480 | msg += ('<b>Email :</b> '+result['email']+'<br/>'); |
482 | 481 | msg += ('<b>Registration date :</b> '+result['date']+'<br/>'); |
483 | - | |
482 | + msg += ('<b>Disk space total / used / available :</b> '+result['total']+' / '+result['used']+' / '+result['available']+' MB<br/>'); | |
484 | 483 | this.infoMsg(msg); |
485 | 484 | } |
486 | 485 | else | ... | ... |
php/classes/AmdaClient.php
... | ... | @@ -12,44 +12,10 @@ |
12 | 12 | class AmdaClient { |
13 | 13 | |
14 | 14 | public $client; |
15 | - public $updateOnly; | |
16 | - | |
17 | - function __construct($updateOnly){ | |
18 | - | |
19 | - $this->updateOnly = $updateOnly; | |
20 | - | |
21 | - /* wsdl location depends on DDServer AMDA is connected to | |
22 | - * DDServer is defined in DD.res | |
23 | - */ | |
24 | - $SERVER = file(DDRES_DIR."/DD.res"); | |
25 | - if (!file_exists(DATAPATH."wsdl.location")) { | |
26 | - $msg = "No WSDL location file -> Nothing done".PHP_EOL; | |
27 | - error_log($msg, 1, email); | |
28 | - exit($msg); | |
29 | - } | |
30 | - | |
31 | - /* Get WSDL Location */ | |
32 | - | |
33 | - $WsdlSources = file(DATAPATH."wsdl.location"); | |
34 | - $isHOST = false; | |
35 | - for ($i = 0; $i < count($WsdlSources); $i++) | |
36 | - { | |
37 | - list($HOST,$WSDL) = sscanf($WsdlSources[$i],"%s %s"); | |
38 | - | |
39 | - if ($HOST.PHP_EOL == $SERVER[0]) { | |
40 | - $isHOST = true; | |
41 | - break; | |
42 | - } | |
43 | - } | |
44 | - | |
45 | - if (!$isHOST) { | |
46 | - $msg = "No WSDL location for ".$SERVER[0].PHP_EOL; | |
47 | - error_log($msg, 1, email); | |
48 | - exit($msg); | |
49 | - } | |
50 | - | |
15 | + | |
16 | + function __construct(){ | |
51 | 17 | try { |
52 | - $this->client = new SoapClient($WSDL); | |
18 | + $this->client = new SoapClient(DD_WSDL); | |
53 | 19 | } |
54 | 20 | catch (SoapFault $exception) { |
55 | 21 | $msg = $exception->faultstring.PHP_EOL; |
... | ... | @@ -57,15 +23,13 @@ class AmdaClient { |
57 | 23 | exit($msg); |
58 | 24 | } |
59 | 25 | // reset log file |
60 | - if (file_exists(log)) unlink(log); | |
26 | + if (file_exists(log)) unlink(log); | |
61 | 27 | |
62 | - date_default_timezone_set('UTC'); | |
28 | + date_default_timezone_set('UTC'); | |
63 | 29 | } |
64 | 30 | |
65 | - /* Just copy URL to Info/Bases.xml */ | |
66 | - | |
31 | + /* Just copy URL to Info/Bases.xml */ | |
67 | 32 | public function getAvailableExternalBases() { |
68 | - | |
69 | 33 | try { |
70 | 34 | $extBases = $this->client->getAvailableExternalBases(); |
71 | 35 | } |
... | ... | @@ -76,457 +40,93 @@ class AmdaClient { |
76 | 40 | } |
77 | 41 | |
78 | 42 | if ($extBases === "NOEXTERNALBASES") { |
79 | - if (!$this->updateOnly) error_log($extBases.PHP_EOL, 1, email); | |
43 | + error_log($extBases.PHP_EOL, 1, email); | |
80 | 44 | return $extBases; |
81 | 45 | } |
82 | 46 | |
83 | 47 | $extBasesDom = new DomDocument("1.0"); |
84 | 48 | if (!$extBasesDom->load($extBases)) { |
85 | 49 | $msg = "Can't load Bases.xml".PHP_EOL; |
86 | - if (!$this->updateOnly) error_log($msg, 1, email); | |
50 | + error_log($msg, 1, email); | |
87 | 51 | exit($msg); |
88 | 52 | } |
89 | 53 | |
90 | - $External = $extBasesDom->getElementsByTagName("External")->item(0); | |
91 | - if ($External == NULL) { | |
92 | - $msg = "no External Tag found in Bases.xml".PHP_EOL; | |
93 | - if (!$this->updateOnly) error_log($msg, 1, email); | |
94 | - exit($msg); | |
95 | - } | |
54 | +// $External = $extBasesDom->getElementsByTagName("External")->item(0); | |
55 | +// if ($External == NULL) { | |
56 | +// $msg = "no External Tag found in Bases.xml".PHP_EOL; | |
57 | +// error_log($msg, 1, email); | |
58 | +// exit($msg); | |
59 | +// } | |
96 | 60 | |
97 | - $extBasesNames = $External->getElementsByTagName("CenterID"); | |
61 | + $extBasesNames = $extBasesDom->getElementsByTagName("dataCenter"); | |
98 | 62 | if ($extBasesNames->length === 0) { |
99 | 63 | $msg = "no external bases found in Bases.xml".PHP_EOL; |
100 | - if (!$this->updateOnly) error_log($msg, 1, email); | |
64 | + error_log($msg, 1, email); | |
101 | 65 | exit($msg); |
102 | 66 | } |
103 | - | |
67 | +/* | |
104 | 68 | if (!$this->updateOnly) { |
105 | - if (!is_dir(RemoteData)) mkdir(RemoteData, 0775, true); | |
106 | - chgrp(RemoteData, APACHE_USER); | |
107 | - chmod(RemoteData, 0775); | |
108 | - if (!is_dir(RemoteData.'PARAMS')) mkdir(RemoteData.'PARAMS', 0775, true); | |
109 | - chgrp(RemoteData.'PARAMS', APACHE_USER); | |
110 | - chmod(RemoteData.'PARAMS', 0775); | |
111 | - | |
112 | - $xsl = new DOMDocument("1.0"); | |
113 | - $xsl->load(XMLPATH."basesRaw2bases.xsl"); | |
114 | - | |
115 | - $xslt = new XSLTProcessor(); | |
116 | - $xslt->importStylesheet($xsl); | |
117 | - | |
118 | - if (!$xslt->transformToDoc($extBasesDom)->save(RemoteData."Bases.xml")){ | |
119 | - $msg = "problem while transforming Bases.xml".PHP_EOL; | |
120 | - error_log($msg, 1, email); | |
121 | - exit($msg); | |
122 | - } | |
123 | - } | |
124 | - return $extBasesNames; | |
125 | - | |
126 | - } | |
127 | - | |
128 | - /* Get list of available local missions for a given user*/ | |
129 | - public function getUserAvailableMissions($user) | |
130 | - { | |
131 | - try { | |
132 | - $localmissions = $this->client->getUserAvailableLocalMissions($user); | |
133 | - $externalmissions = $this->client->getUserAvailableExternalMissions($user); | |
134 | - } | |
135 | - catch (SoapFault $exception) { | |
136 | - | |
137 | - /*$log = fopen(DATAPATH."mylog","w"); | |
138 | - fprintf($log,$exception->faultstring."\n"); | |
139 | - | |
140 | - $functions = $this->client->__getFunctions (); | |
141 | - foreach ($functions as $function) | |
142 | - fprintf($log,$function."\n");*/ | |
143 | - return array('success' => false,'message' => $exception->faultstring); | |
144 | - } | |
145 | - | |
146 | - return array('success' => true,'local' => $localmissions,'external' => $externalmissions); | |
69 | + if (!is_dir(RemoteData)) mkdir(RemoteData, 0775, true); | |
70 | + chgrp(RemoteData, APACHE_USER); | |
71 | + chmod(RemoteData, 0775); | |
72 | + if (!is_dir(RemoteData.'PARAMS')) mkdir(RemoteData.'PARAMS', 0775, true); | |
73 | + chgrp(RemoteData.'PARAMS', APACHE_USER); | |
74 | + chmod(RemoteData.'PARAMS', 0775); | |
75 | + | |
76 | + $xsl = new DOMDocument("1.0"); | |
77 | + $xsl->load(XMLPATH."basesRaw2bases.xsl"); | |
78 | + | |
79 | + $xslt = new XSLTProcessor(); | |
80 | + $xslt->importStylesheet($xsl); | |
81 | + | |
82 | + if (!$xslt->transformToDoc($extBasesDom)->save(RemoteData."Bases.xml")){ | |
83 | + $msg = "problem while transforming Bases.xml".PHP_EOL; | |
84 | + error_log($msg, 1, email); | |
85 | + exit($msg); | |
86 | + } | |
87 | + }*/ | |
88 | + return $extBasesNames; | |
147 | 89 | } |
148 | 90 | |
149 | 91 | /* Just copy URL to LocalData/Amda_Users.xml */ |
150 | 92 | |
151 | - public function getUserGroups() { | |
152 | - try { | |
153 | - $group_info = $this->client->getUserGroups(); | |
154 | - } | |
155 | - catch (SoapFault $exception) { | |
156 | - exit("Problems with DD Web Services".PHP_EOL); | |
157 | - } | |
158 | - if ($group_info === "NOUSERGROUPSSPECIFIED") return false; | |
159 | - | |
160 | - if (!file_exists(LocalData)) mkdir(LocalData, 0755, true); | |
161 | - if (!copy($group_info,LocalData."AMDA_Users.xml")) | |
162 | - exit("problem with copying AMDA_Users info".PHP_EOL); | |
163 | - | |
164 | - return true; | |
165 | - | |
166 | - } | |
167 | - /* Get Time Restriction from VI in DDBASE */ | |
168 | - | |
169 | - public function getTimeRestriction($dataSet) { | |
170 | - try { | |
171 | - $restrictions = $this->client->getTimeRestriction($dataSet); | |
172 | - } | |
173 | - catch (SoapFault $exception) { | |
174 | - error_log($exception->faultstring.PHP_EOL, 1, email); | |
175 | - return FALSE; | |
176 | - } | |
177 | - if ($restrictions['success'] === FALSE) { | |
178 | - error_log('TimeRestriction: '.$dataSet.' '.$restrictions['days'], 1, email); | |
179 | - return FALSE; | |
180 | - } | |
181 | - | |
182 | - return $restrictions; | |
183 | - | |
184 | - } | |
185 | - /* Just copy URL to LocalData/Missions.xml */ | |
186 | - | |
187 | - public function getAvailableMissions() { | |
188 | - | |
93 | +// public function getUserGroups() { | |
94 | +// try { | |
95 | +// $group_info = $this->client->getUserGroups(); | |
96 | +// } | |
97 | +// catch (SoapFault $exception) { | |
98 | +// exit("Problems with DD Web Services".PHP_EOL); | |
99 | +// } | |
100 | +// if ($group_info === "NOUSERGROUPSSPECIFIED") return false; | |
101 | +// | |
102 | +// if (!file_exists(LocalData)) mkdir(LocalData, 0755, true); | |
103 | +// | |
104 | +// if (!copy($group_info,LocalData."AMDA_Users.xml")) | |
105 | +// exit("problem with copying AMDA_Users info".PHP_EOL); | |
106 | +// | |
107 | +// return true; | |
108 | +// } | |
109 | +// | |
110 | + /* Get Time Restriction from VI in DDBASE */ | |
111 | + public function getTimeRestriction($dataSet) { | |
189 | 112 | try { |
190 | - $localMissions = $this->client->getAvailableMissions(); | |
191 | - } | |
192 | - catch (SoapFault $exception) { | |
193 | - $msg = $exception->faultstring.PHP_EOL; | |
194 | - if (!$this->updateOnly) error_log($msg, 1, email); | |
195 | - exit($msg); | |
113 | + $restrictions = $this->client->getTimeRestriction($dataSet); | |
196 | 114 | } |
197 | - | |
198 | - if ($localMissions === "NOLOCALDATA") { | |
199 | - if (!$this->updateOnly) error_log($localMissions.PHP_EOL, 1, email); | |
200 | - return $localMissions; | |
201 | - } | |
202 | - | |
203 | - $locBasesDom = new DomDocument("1.0"); | |
204 | - $locBasesDom->load($localMissions); | |
205 | - $local = $locBasesDom->getElementsByTagName("Local")->item(0); | |
206 | - | |
207 | - if (!$local) { | |
208 | - $msg = "no local data found in Missions.xml".PHP_EOL; | |
209 | - if (!$this->updateOnly) error_log($msg, 1, email); | |
210 | - exit($msg); | |
211 | - } | |
212 | - | |
213 | - $locBasesNames = $local->getElementsByTagName("MissionID"); | |
214 | - if ($locBasesNames->length === 0) { | |
215 | - $msg = "no missions found in Missions.xml".PHP_EOL; | |
216 | - error_log($msg, 1, email); | |
217 | - exit($msg); | |
115 | + catch (SoapFault $exception) { | |
116 | + error_log($exception->faultstring.PHP_EOL, 1, email); | |
117 | + return FALSE; | |
218 | 118 | } |
219 | - | |
220 | - if (!is_dir(LocalData)) mkdir(LocalData, 0775, true); | |
221 | - if (!is_dir(LocalDataParam)) mkdir(LocalDataParam, 0775, true); | |
222 | - if (!is_dir(LocalDataTemplate)) mkdir(LocalDataTemplate, 0775, true); | |
223 | - | |
224 | - chgrp(LocalData,APACHE_USER); | |
225 | - chgrp(LocalDataParam,APACHE_USER); | |
226 | - chgrp(LocalDataTemplate,APACHE_USER); | |
227 | - | |
228 | - chmod(LocalData, 0775); | |
229 | - chmod(LocalDataParam, 0775); | |
230 | - chmod(LocalDataTemplate, 0775); | |
231 | - | |
232 | - if (!copy($localMissions,LocalData."Missions.xml")) { | |
233 | - $msg = "problem with copying AMDA Local Missions info".PHP_EOL; | |
234 | - if (!$this->updateOnly) error_log($msg, 1, email); | |
235 | - exit($msgL); | |
119 | + if ($restrictions['success'] === FALSE) { | |
120 | + error_log('TimeRestriction: '.$dataSet.' '.$restrictions['days'], 1, email); | |
121 | + return FALSE; | |
236 | 122 | } |
237 | - | |
238 | - return $locBasesNames; | |
239 | - | |
123 | + | |
124 | + return $restrictions; | |
125 | + | |
240 | 126 | } |
241 | - | |
242 | - public function isMulti($baseNode){ | |
243 | - $multi = $baseNode->getAttribute("missions"); | |
244 | - if ($multi == "") return false; | |
245 | - $nameArr = explode(";",$multi); | |
246 | - if (count($nameArr) < 2) return false; | |
247 | - | |
248 | - return $nameArr; | |
249 | - } | |
250 | - | |
251 | - | |
252 | - public function makeMulti($locbase, $multiNames){ | |
253 | - | |
254 | - $templatename = LocalDataTemplate."DD_".$locbase->nodeValue.".template"; | |
255 | - $paramtemplate = LocalDataTemplate.$locbase->nodeValue.".template"; | |
256 | - | |
257 | - $suffix = array(); | |
258 | - foreach ($multiNames as $item) { | |
259 | - $temp = explode("-",$item); | |
260 | - if (count($temp) > 1) { | |
261 | - $suffix[] = $temp[1]; | |
262 | - } | |
263 | - else { | |
264 | - $suffix[] = substr($item,-1); | |
265 | - } | |
266 | - } | |
267 | - | |
268 | - $template = new DomDocument("1.0"); | |
269 | - $status = $template->load($templatename); | |
270 | - if (!$status) { | |
271 | - print_r("Cannot load ".$templatename.PHP_EOL); | |
272 | - if (!$this->updateOnly) error_log("Cannot load ".$templatename.PHP_EOL,1,email); | |
273 | - } | |
274 | - | |
275 | - $paramdom = new DomDocument("1.0"); | |
276 | - $status = $paramdom->load($paramtemplate); | |
277 | - if (!$status) { | |
278 | - print_r("Cannot load ".$paramtemplate.PHP_EOL); | |
279 | - if (!$this->updateOnly) error_log("Cannot load ".$paramtemplate.PHP_EOL,1,email); | |
280 | - } | |
281 | - | |
282 | - // Create DD_Mission.xml | |
283 | - $locbasename = LocalData."DD_".$locbase->nodeValue.".xml"; | |
284 | - $locbasedom = new DomDocument("1.0"); | |
285 | - $root = $locbasedom->importNode($template->documentElement); | |
286 | - $amda = $locbasedom->importNode($template->getElementsByTagName("dataCenter")->item(0)); | |
287 | - $missionMain = $locbasedom->importNode($template->getElementsByTagName("mission")->item(0)); | |
288 | 127 | |
289 | - $mission = $locbasedom->importNode($template->getElementsByTagName("mission")->item(0), true); | |
290 | - | |
291 | - $targets = $mission->getElementsByTagName("target"); | |
292 | - $targetNames = array(); | |
293 | - foreach ($targets as $target) | |
294 | - if ($target->parentNode->tagName == 'mission') // mission only targets | |
295 | - $targetNames[] = $target->nodeValue; | |
296 | - | |
297 | - $observatory = $mission->getElementsByTagName("observatory")->item(0); | |
298 | - $instruments = $observatory->getElementsByTagName("instrument"); | |
299 | - | |
300 | - // create param descriptor Mission.xml | |
301 | - $parambasename = LocalDataParam.$locbase->nodeValue.".xml"; | |
302 | - $parambasedom = new DomDocument("1.0"); | |
303 | - $paramroot = $parambasedom->importNode($paramdom->documentElement); | |
304 | - | |
305 | - $instrumentNon = array(); | |
306 | - foreach ($instruments as $instrument) { | |
307 | - // absent instriments processing | |
308 | - if ($instrument->hasAttribute("absent")) { | |
309 | - $absent = $instrument->getAttribute("absent"); | |
310 | - $absentArray = explode(";",$absent); | |
311 | - $tempArr = array(); | |
312 | - | |
313 | - if (count($absentArray) > 1) { | |
314 | - for ($i = 0; $i < count($suffix); $i++) $tempArr[$i] = false; | |
315 | - for ($j = 0; $j < count($absentArray); $j++) { | |
316 | - $temp = array_search($absentArray[$j], $suffix, true); | |
317 | - $tempArr[$temp] = true; | |
318 | - } | |
319 | - | |
320 | - } | |
321 | - else { | |
322 | - for ($i = 0; $i < count($suffix); $i++) { | |
323 | - $tempArr[$i] = $absent == $suffix[$i]; | |
324 | - } | |
325 | - } | |
326 | - $instrumentNon[$instrument->getAttribute("name")] = $tempArr; | |
327 | - } | |
328 | - } | |
329 | - | |
330 | - foreach ($targetNames as $targetName) { | |
331 | - $missionMain->appendChild($locbasedom->createElement("target",$targetName)); | |
332 | - } | |
333 | - | |
334 | - for ($index = 0; $index < count($suffix); $index++) { | |
335 | - | |
336 | - $missionArr[$index] = $observatory->cloneNode(); | |
337 | - $missionArr[$index]->setAttribute("name", str_replace("XXX", $suffix[$index], $missionArr[$index]->getAttribute("name"))); | |
338 | - $missionArr[$index]->setAttribute("xml:id", str_replace("XXX", $suffix[$index], $missionArr[$index]->getAttribute("name"))); | |
339 | - $instruments = $observatory->getElementsByTagName("instrument"); | |
340 | - | |
341 | - foreach ($instruments as $instrumentReal){ | |
342 | - if (!$instrumentNon[$instrumentReal->getAttribute("name")] || !$instrumentNon[$instrumentReal->getAttribute("name")][$index]) { | |
343 | - $instrument = $instrumentReal->cloneNode(true); | |
344 | - $instrument->setAttribute("desc",str_replace("XXX", $suffix[$index], $instrument->getAttribute("desc"))); | |
345 | - $instrument->setAttribute("xml:id",str_replace("XXX", $suffix[$index], $instrument->getAttribute("xml:id"))); | |
346 | - $tags = array("dataset", "parameter", "component"); | |
347 | - | |
348 | - foreach ($tags as $tag) { | |
349 | - $all = $instrument->getElementsByTagName($tag); | |
350 | - foreach ($all as $one) { | |
351 | - if ($tag == 'parameter') { | |
352 | - $id = $one->getAttribute("xml:id"); | |
353 | - // create param tag in param XML descriptor | |
354 | - $param = $paramdom->getElementById($id); | |
355 | - if ($param){ | |
356 | - $paramAdd = $parambasedom->importNode($param, true); | |
357 | - $paramAdd->setAttribute("xml:id",str_replace("XXX", strtolower($suffix[$index]), $id)); | |
358 | - $paramAdd->setAttribute("vi",str_replace("XXX", strtolower($suffix[$index]), $paramAdd->getAttribute("vi"))); | |
359 | - $yTitle = $paramAdd->getElementsByTagName("YTITLE"); | |
360 | - if ($yTitle->length > 0) { | |
361 | - $value = $yTitle->item(0)->nodeValue; | |
362 | - $yTitle->item(0)->nodeValue = str_replace("XXX", $suffix[$index], $value); | |
363 | - } | |
364 | - $paramroot->appendChild($paramAdd); | |
365 | - } | |
366 | - } | |
367 | - $one->setAttribute("xml:id",str_replace("XXX", strtolower($suffix[$index]), $one->getAttribute("xml:id"))); | |
368 | - if ($tag == 'dataset' && $one->hasAttribute("vi")) | |
369 | - $one->setAttribute("vi",str_replace("XXX", strtolower($suffix[$index]), $one->getAttribute("vi"))); | |
370 | - } | |
371 | - } | |
372 | - | |
373 | - //apply to new tags included for EPNResources | |
374 | - $all = $instrument->getElementsByTagName("alternateName"); | |
375 | - foreach ($all as $one) | |
376 | - $one->nodeValue = str_replace("XXX", strtolower($suffix[$index]), $one->nodeValue); | |
377 | - | |
378 | - $datasets = $instrument->getElementsByTagName("dataset"); | |
379 | - foreach ($datasets as $dataset) | |
380 | - { | |
381 | - $info = $dataset->getElementsByTagName("info"); | |
382 | - if ($info->length > 0) | |
383 | - { | |
384 | - $info = $info->item(0); | |
385 | - | |
386 | - $title = $info->getElementsByTagName("title"); | |
387 | - if ($title->length > 0) | |
388 | - { | |
389 | - $title = $title->item(0); | |
390 | - $title->nodeValue = str_replace("XXX", strtolower($suffix[$index]), $title->nodeValue); | |
391 | - } | |
392 | - | |
393 | - $desc = $info->getElementsByTagName("description"); | |
394 | - if ($desc->length > 0) | |
395 | - { | |
396 | - $desc = $desc->item(0); | |
397 | - $desc->nodeValue = str_replace("XXX", strtolower($suffix[$index]), $desc->nodeValue); | |
398 | - } | |
399 | - | |
400 | - $targets = $info->getElementsByTagName("target"); | |
401 | - foreach ($targets as $target) | |
402 | - $target->nodeValue = str_replace("XXX", strtolower($suffix[$index]), $target->nodeValue); | |
403 | - } | |
404 | - } | |
405 | - | |
406 | - $missionArr[$index]->appendChild($instrument); | |
407 | - } | |
408 | - } | |
409 | - $missionMain->appendChild($missionArr[$index]); | |
410 | - } | |
411 | - | |
412 | - $amda->appendChild($missionMain); | |
413 | - $root->appendChild($amda); | |
414 | - $locbasedom->appendChild($root); | |
415 | - $status = $locbasedom->save($locbasename); | |
416 | - if (!$status) { | |
417 | - print_r("Cannot save ".$locbasename.PHP_EOL); | |
418 | - error_log("Cannot save ".$locbasename.PHP_EOL,3,log); | |
419 | - } | |
420 | - $parambasedom->appendChild($paramroot); | |
421 | - $status = $parambasedom->save($parambasename); | |
422 | - if (!$status) { | |
423 | - print_r("Cannot save ".$parambasename.PHP_EOL); | |
424 | - error_log("Cannot save ".$parambasename.PHP_EOL,3,log); | |
425 | - } | |
426 | - } | |
427 | - | |
428 | - public function getDDLocalParamsFiles($locBases) | |
429 | - { | |
430 | - if (!$this->updateOnly) | |
431 | - { | |
432 | - //remove old DD_*.xml files (install mode) | |
433 | - foreach (glob(LocalData."DD_*.xml") as $file) | |
434 | - unlink($file); | |
435 | - //remove old local parameters files | |
436 | - foreach (glob(LocalDataParam."*.xml") as $file) | |
437 | - unlink($file); | |
438 | - //remove old template (install mode) | |
439 | - foreach (glob(LocalDataTemplate."*.template") as $file) | |
440 | - unlink($file); | |
441 | - | |
442 | - if (file_exists(spectraXml)) unlink(spectraXml); | |
443 | - //remove old targets file | |
444 | - if (file_exists(targetsXml)) unlink(targetsXml); | |
445 | - | |
446 | - //if (!is_dir(LocalDataTemplate)) mkdir(LocalDataTemplate); | |
447 | - } | |
448 | - | |
449 | - foreach ($locBases as $locbase) | |
450 | - { | |
451 | - $ddfilename = "DD_".$locbase->nodeValue.".xml"; | |
452 | - $ddparamfilename = $locbase->nodeValue.".xml"; | |
453 | - $ddtemplate = "DD_".$locbase->nodeValue.".template"; | |
454 | - $ddparamtemplate = $locbase->nodeValue.".template"; | |
455 | - | |
456 | - //get DD_*.xml or DD_*template file | |
457 | - $multiNames = $this->isMulti($locbase); | |
458 | - | |
459 | - if (!$this->updateOnly || !file_exists(LocalData.$ddfilename)) { | |
460 | - if ($multiNames) | |
461 | - system("svn export ".SVN_TEMPLATES.$ddtemplate." ".LocalDataTemplate.$ddtemplate); | |
462 | - else | |
463 | - system("svn export ".SVN_DDMISSIONSINFO.$ddfilename." ".LocalData.$ddfilename); | |
464 | - } | |
465 | - //get local params for this mission | |
466 | - if (!$this->updateOnly || !file_exists(LocalDataParam.$ddparamfilename)) { | |
467 | - if ($multiNames) | |
468 | - system("svn export ".SVN_TEMPLATES.$ddparamtemplate." ".LocalDataTemplate.$ddparamtemplate); | |
469 | - else | |
470 | - system("svn export ".SVN_LOCALPARAMSINFO.$ddparamfilename." ".LocalDataParam.$ddparamfilename); | |
471 | - } | |
472 | - | |
473 | - if ($multiNames && !$this->updateOnly) $this->makeMulti($locbase, $multiNames); | |
474 | - } | |
475 | - | |
476 | - | |
477 | - //get SpectraParamList.xml | |
478 | - if (!$this->updateOnly) { | |
479 | - system("svn export ".SVN_DDMISSIONSINFO."SpectraParamList.xml ".spectraXml); | |
480 | - } | |
481 | - //get targets.xml | |
482 | - if (!$this->updateOnly) { | |
483 | - system("svn export ".SVN_DDMISSIONSINFO."targets.xml ".targetsXml); | |
484 | - } | |
485 | - | |
486 | - //merge local params for each missions in LocalParams.xml + generate LocalParamsList.xml | |
487 | - if (!$this->updateOnly) | |
488 | - { | |
489 | - $paramsDom = new DomDocument("1.0"); | |
490 | - $paramsDom->formatOutput = true; | |
491 | - $paramsDom->preserveWhiteSpace = false; | |
492 | - $paramsRoot = $paramsDom->createElement('LOCAL'); | |
493 | - $paramsDom->appendChild($paramsRoot); | |
494 | - | |
495 | - $listDom = new DomDocument("1.0"); | |
496 | - $listDom->formatOutput = true; | |
497 | - $listDom->preserveWhiteSpace = false; | |
498 | - $listRoot = $listDom->createElement('LOCAL'); | |
499 | - $listDom->appendChild($listRoot); | |
500 | - $dom = new DomDocument("1.0"); | |
501 | - | |
502 | - foreach ($locBases as $locbase) | |
503 | - { | |
504 | - $ddparamfilename = $locbase->nodeValue.".xml"; | |
505 | - $dom->load(LocalDataParam.$ddparamfilename); | |
506 | - | |
507 | - $params = $dom->getElementsByTagName('PARAM'); | |
508 | - | |
509 | - foreach ($params as $param) | |
510 | - { | |
511 | - $node = $paramsDom->importNode($param,TRUE); | |
512 | - $paramsRoot->appendChild($node); | |
513 | - | |
514 | - $id = $param->getAttribute('xml:id'); | |
515 | - $node = $listDom->createElement('PARAM',$id); | |
516 | - $listRoot->appendChild($node); | |
517 | - } | |
518 | - } | |
519 | - | |
520 | - $paramsDom->save(paramXml); | |
521 | - $listDom->save(paramListXml); | |
522 | - } | |
523 | - | |
524 | - } | |
525 | - | |
526 | - /* Just copy URL to DATA/$BaseID/base.xml */ | |
527 | - | |
128 | + /* Just copy URL to DATA/$BaseID/base.xml */ | |
528 | 129 | public function getAvailableExternalData($BaseID) { |
529 | - | |
530 | 130 | try { |
531 | 131 | $extData = $this->client->getAvailableExternalData($BaseID); |
532 | 132 | } |
... | ... | @@ -537,106 +137,31 @@ class AmdaClient { |
537 | 137 | } |
538 | 138 | |
539 | 139 | if ($extData === "NOEXTERNALDATA") return false; |
540 | -//drwxrwxr-x | |
541 | - if (!$this->updateOnly) { | |
542 | - if (!file_exists(RemoteData.$BaseID)) mkdir(RemoteData.$BaseID, 0775, true); | |
543 | - chgrp(RemoteData.$BaseID, APACHE_USER); | |
544 | - chmod(RemoteData.$BaseID, 0775); | |
545 | - } | |
140 | + //drwxrwxr-x | |
141 | + if (!$this->updateOnly) { | |
142 | + if (!file_exists(RemoteData.$BaseID)) mkdir(RemoteData.$BaseID, 0775, true); | |
143 | + chgrp(RemoteData.$BaseID, APACHE_USER); | |
144 | + chmod(RemoteData.$BaseID, 0775); | |
145 | + } | |
546 | 146 | |
547 | 147 | if (!copy($extData,RemoteData.$BaseID."/base.xml")) { |
548 | 148 | $msg = "problem with copying base.xml for ".$BaseID.PHP_EOL; |
549 | - if (!$this->updateOnly) error_log($msg, 1, email); | |
149 | + error_log($msg, 1, email); | |
550 | 150 | exit($msg); |
551 | 151 | } |
552 | 152 | |
553 | - return true; | |
554 | - | |
153 | + return true; | |
555 | 154 | } |
556 | 155 | |
557 | - function days2MonthDay($oldDate, $addDay) | |
558 | - { | |
156 | + function days2MonthDay($oldDate, $addDay){ | |
559 | 157 | list($year, $day, $hour, $min, $sec) = sscanf($oldDate, "%04d%03d%02d%02d%02d"); |
560 | 158 | |
561 | - if ($addDay) $day++; | |
562 | - | |
563 | - $newDate = date("Y/m/d",strtotime("+$day days",strtotime("$year-01-01 $hour:$min:$sec"))); | |
159 | + if ($addDay) $day++; | |
160 | + $newDate = date("Y/m/d",strtotime("+$day days",strtotime("$year-01-01 $hour:$min:$sec"))); | |
564 | 161 | |
565 | 162 | return $newDate; |
566 | 163 | } |
567 | - | |
568 | - /* Update Local Bases Start - Stop */ | |
569 | - | |
570 | - public function updateStartStop($groups){ | |
571 | - | |
572 | - for ($k = 0; $k < $groups->length; $k++) | |
573 | - { | |
574 | - if (strpos($groups->item($k)->nodeValue, 'Models') !== false ) continue; | |
575 | - | |
576 | - $domName = LocalData."DD_".$groups->item($k)->nodeValue.".xml"; | |
577 | - $dom = new DomDocument(); | |
578 | - if (!$dom->load($domName)) | |
579 | - { | |
580 | - $msg = "Cannot load file ".$domName.PHP_EOL; | |
581 | - print_r($msg); | |
582 | - if (!$this->updateOnly) error_log($msg,1,email); | |
583 | - continue; | |
584 | - } | |
585 | - | |
586 | - $vi = $dom -> getElementsByTagName("dataset"); | |
587 | - if ($vi->length > 0) for ($i = 0; $i < $vi->length; $i++) | |
588 | - { | |
589 | - | |
590 | - // PHP sur manunja $name = $vi->item($i)->getAttribute('id'); | |
591 | - $name = $vi->item($i)->getAttribute('xml:id'); | |
592 | - | |
593 | - $hasVersion = $vi->item($i)->hasAttribute('version'); | |
594 | - | |
595 | - if ($vi->item($i)->getAttribute('vi') != '') | |
596 | - $name = $vi->item($i)->getAttribute('vi'); | |
597 | - if ($name){ | |
598 | - try | |
599 | - { | |
600 | - // Call AMDA WebService | |
601 | - $res = $this->client->getStartStop($name); | |
602 | - $Time = explode("-",$res); | |
603 | - $msg = $name." : ".$res.PHP_EOL; | |
604 | - | |
605 | - // New Start - New Stop | |
606 | - $newStart = $this->days2MonthDay($Time[0]); | |
607 | - $vi->item($i)->getElementsByTagName('dataStart')->item(0)->nodeValue = $newStart; | |
608 | - | |
609 | - $newStop = $this->days2MonthDay($Time[1]); | |
610 | - if ($newStart == $newStop) $newStop = $this->days2MonthDay($Time[1], true); | |
611 | - | |
612 | - $vi->item($i)->getElementsByTagName('dataStop')->item(0)->nodeValue = $newStop; | |
613 | - if ($hasVersion) { | |
614 | - $res = $this->client->getVersion(str_replace(":", "_", $name)); | |
615 | - if ($res) { | |
616 | - $dataSource = explode("//", $vi->item($i)->getElementsByTagName('dataSource')->item(0)->nodeValue); | |
617 | - $vi->item($i)->getElementsByTagName('dataSource')->item(0)->nodeValue = "$dataSource[0]//$res"; | |
618 | - } | |
619 | - } | |
620 | - | |
621 | - } | |
622 | - catch (SoapFault $exception) | |
623 | - { | |
624 | - $msg = $exception->faultstring." : DataSet ".$name." Start-Stop can't be updated".PHP_EOL; | |
625 | - print_r($msg); | |
626 | - if (!$this->updateOnly) error_log($msg,1,email); | |
627 | - } | |
628 | - } | |
629 | - else echo "Models SINP not data".PHP_EOL; | |
630 | - | |
631 | - } | |
632 | - if (!$dom->save($domName)){ | |
633 | - error_log("Cannot save LocalParams.xml".PHP_EOL,1,email); | |
634 | - } | |
635 | - } | |
636 | - return true; | |
637 | - } | |
638 | - | |
639 | - | |
164 | + | |
640 | 165 | /* Update Remote Bases Start - Stop */ |
641 | 166 | |
642 | 167 | public function updateRemoteStartStop($extBaseID){ |
... | ... | @@ -646,7 +171,7 @@ class AmdaClient { |
646 | 171 | if (!$dom->load($domName)){ |
647 | 172 | $msg = "Cannot load file ".$domName.PHP_EOL; |
648 | 173 | print_r($msg); |
649 | - if (!$this->updateOnly) error_log($msg,1,email); | |
174 | + error_log($msg,1,email); | |
650 | 175 | return false;; |
651 | 176 | } |
652 | 177 | |
... | ... | @@ -674,96 +199,59 @@ class AmdaClient { |
674 | 199 | } |
675 | 200 | |
676 | 201 | /* Check Remote Bases Connection */ |
677 | - public function checkRemoteConnection($extBaseID){ | |
678 | - try { | |
679 | - $res = $this->client->checkRemoteConnection($extBaseID); | |
680 | - | |
681 | - } | |
682 | - catch (SoapFault $exception) | |
683 | - { | |
684 | - print_r($exception->faultstring.PHP_EOL); | |
685 | - error_log($exception->faultstring.PHP_EOL,1,email); | |
686 | - return false; | |
687 | - } | |
688 | - | |
689 | - return $res; | |
690 | - } | |
202 | +// public function checkRemoteConnection($extBaseID){ | |
203 | +// try { | |
204 | +// $res = $this->client->checkRemoteConnection($extBaseID); | |
205 | +// | |
206 | +// } | |
207 | +// catch (SoapFault $exception) | |
208 | +// { | |
209 | +// print_r($exception->faultstring.PHP_EOL); | |
210 | +// error_log($exception->faultstring.PHP_EOL,1,email); | |
211 | +// return false; | |
212 | +// } | |
213 | +// | |
214 | +// return $res; | |
215 | +// } | |
691 | 216 | |
692 | 217 | /* Get user info from login */ |
693 | 218 | public function getUserInfo($login) { |
694 | 219 | try { |
695 | - $info = $this->client->getUserInfo($login,md5(DDSERVICE_PRIVATEKEY.$login.'getUserInfo')); //error_log($info,1,email); | |
220 | + $info = $this->client->getUserInfo($login,md5(DDSERVICE_PRIVATEKEY.$login.'getUserInfo')); | |
696 | 221 | } |
697 | 222 | catch (SoapFault $exception) { |
698 | 223 | return array('success' => false, 'message' => $exception->faultstring); |
699 | - } | |
700 | - | |
701 | - | |
224 | + } | |
702 | 225 | return $info; |
703 | 226 | } |
227 | + | |
704 | 228 | /* Get data set info */ |
705 | - public function getInfo($viID, $infoID) { | |
706 | - try { | |
707 | - $info = $this->client->getInfo($viID, $infoID); | |
708 | - } | |
709 | - catch (SoapFault $exception) { | |
710 | - return array('success' => false, 'message' => $exception->faultstring); | |
711 | - } | |
229 | +// public function getInfo($viID, $infoID) { | |
230 | +// try { | |
231 | +// $info = $this->client->getInfo($viID, $infoID); | |
232 | +// } | |
233 | +// catch (SoapFault $exception) { | |
234 | +// return array('success' => false, 'message' => $exception->faultstring); | |
235 | +// } | |
236 | +// return $info; | |
237 | +// } | |
238 | + | |
239 | +/* Recursively modify rights & grp */ | |
240 | +// public function fsmodify($obj) { | |
241 | +// chgrp($obj, APACHE_USER); | |
242 | +// chmod($obj, is_dir($obj) ? 0775 : 0664); | |
243 | +// } | |
244 | +// | |
245 | +// public function fsmodifyr($dir) | |
246 | +// { | |
247 | +// if($objs = glob($dir."/*")) { | |
248 | +// foreach($objs as $obj) { | |
249 | +// $this->fsmodify($obj); | |
250 | +// if(is_dir($obj)) $this->fsmodifyr($obj); | |
251 | +// } | |
252 | +// } | |
253 | +// return $this->fsmodify($dir); | |
254 | +// } | |
712 | 255 | |
713 | - | |
714 | - return $info; | |
715 | - } | |
716 | - | |
717 | - /* Recursively modify rights & grp */ | |
718 | - public function fsmodify($obj) { | |
719 | - chgrp($obj, APACHE_USER); | |
720 | - chmod($obj, is_dir($obj) ? 0775 : 0664); | |
721 | - } | |
722 | - | |
723 | - | |
724 | - public function fsmodifyr($dir) | |
725 | - { | |
726 | - if($objs = glob($dir."/*")) { | |
727 | - foreach($objs as $obj) { | |
728 | - $this->fsmodify($obj); | |
729 | - if(is_dir($obj)) $this->fsmodifyr($obj); | |
730 | - } | |
731 | - } | |
732 | - return $this->fsmodify($dir); | |
733 | - } | |
734 | - | |
735 | - /* get Spice Kernels from DDBASE/INFO and copy into AMDALIB/spice */ | |
736 | -/* public function updateSpiceKernels() { | |
737 | - | |
738 | - $kernels = array('general','stereo'); | |
739 | - | |
740 | - $spiceDir = DDHOME."AMDALIB/spice"; | |
741 | - | |
742 | - if (!is_dir($spiceDir)) { | |
743 | - mkdir($spiceDir, 0775, true); | |
744 | - chgrp($spiceDir, APACHE_USER); | |
745 | - chmod($spiceDir, 0775); | |
746 | - } | |
747 | - | |
748 | - chdir($spiceDir); | |
749 | - | |
750 | - foreach ($kernels as $kernel) { | |
751 | - try { | |
752 | - | |
753 | - if (!copy($tarFileURL,$tarFile)){ | |
754 | -// | |
755 | - } | |
756 | - else { | |
757 | - exec('tar -xf '.$tarFile); | |
758 | - } | |
759 | - } | |
760 | - catch (SoapFault $exception) { | |
761 | - $msg = $exception->faultstring.PHP_EOL; | |
762 | - | |
763 | - error_log($msg,1 , email); | |
764 | - } | |
765 | - } | |
766 | - } | |
767 | -*/ | |
768 | 256 | } |
769 | 257 | ... | ... |
php/classes/UserMgr.php
... | ... | @@ -21,7 +21,7 @@ class UserMgr |
21 | 21 | protected $userDirs = array('USERWSDIR' => 'WS', 'USERREQDIR' => 'REQ', 'USERDATADIR' => 'DATA', |
22 | 22 | 'USERWORKINGDIR' =>'RES', 'USERTTDIR' => 'TT', 'USERJOBDIR' => 'JOBS', |
23 | 23 | 'USERTEMPDIR' => 'TEMP'); |
24 | - protected $userMissions; | |
24 | + protected $userGrps; | |
25 | 25 | protected $amdaClient; //client to dd webservice |
26 | 26 | |
27 | 27 | public $isFirst = false; |
... | ... | @@ -31,15 +31,11 @@ class UserMgr |
31 | 31 | function __construct($username = NULL, $password = NULL, $sessionID = NULL) |
32 | 32 | { |
33 | 33 | // if magic quotes is on, stripslashes |
34 | - if(get_magic_quotes_gpc()) | |
35 | - { | |
34 | + if(get_magic_quotes_gpc()) { | |
36 | 35 | $in = array(&$_GET, &$_POST, &$_COOKIE); |
37 | - while(list($k,$v) = each($in)) | |
38 | - { | |
39 | - foreach($v as $key => $val) | |
40 | - { | |
41 | - if(!is_array($val)) | |
42 | - { | |
36 | + while(list($k,$v) = each($in)) { | |
37 | + foreach($v as $key => $val) { | |
38 | + if(!is_array($val)) { | |
43 | 39 | $in[$k][$key] = stripslashes($val); |
44 | 40 | continue; |
45 | 41 | } |
... | ... | @@ -49,15 +45,12 @@ class UserMgr |
49 | 45 | unset($in); |
50 | 46 | } |
51 | 47 | |
52 | - if (isset($_POST['username'])) | |
53 | - { | |
48 | + if (isset($_POST['username'])) { | |
54 | 49 | // Process Guest Login |
55 | - if (strcasecmp(trim($_POST['username']),"guest") == 0) | |
56 | - { | |
50 | + if (strcasecmp(trim($_POST['username']),"guest") == 0) { | |
57 | 51 | $this->processGuestLogin(); |
58 | 52 | } |
59 | - else | |
60 | - { | |
53 | + else { | |
61 | 54 | $this->user = trim($_POST['username']); |
62 | 55 | } |
63 | 56 | } |
... | ... | @@ -65,8 +58,7 @@ class UserMgr |
65 | 58 | $this->user = trim($username); |
66 | 59 | |
67 | 60 | //TODO crypt / decrypt |
68 | - if (!isset($this->passwd)) | |
69 | - { | |
61 | + if (!isset($this->passwd)) { | |
70 | 62 | if (isset($_POST['password'])) |
71 | 63 | $this->passwd = $_POST['password']; |
72 | 64 | else if (isset($password)) |
... | ... | @@ -77,7 +69,8 @@ class UserMgr |
77 | 69 | $this->user = $_GET['sessionID']; |
78 | 70 | else if (isset($sessionID)) |
79 | 71 | $this->user = $sessionID; |
80 | - // $this->amdaClient = new AmdaClient(); | |
72 | + //TODO if AmdaClient is needed ? | |
73 | + $this->amdaClient = new AmdaClient(); | |
81 | 74 | } |
82 | 75 | |
83 | 76 | //TODO if needed?? set session ID |
... | ... | @@ -94,8 +87,9 @@ class UserMgr |
94 | 87 | */ |
95 | 88 | if (getenv('REMOTE_ADDR')) |
96 | 89 | { |
97 | - $realIP = getenv('REMOTE_ADDR'); | |
98 | - if ($realIP == '10.10.131.1') { // proxy amdatest et openam | |
90 | + $realIP = getenv('REMOTE_ADDR'); | |
91 | + | |
92 | + if ($realIP == '10.10.131.1' || $realIP == '10.10.135.119') { // proxy amdatest et openam; amdadev | |
99 | 93 | $allIPs = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
100 | 94 | $realIP = count($allIPs) > 1 ? trim($allIPs[0]) : $_SERVER['HTTP_X_FORWARDED_FOR']; |
101 | 95 | } |
... | ... | @@ -111,52 +105,57 @@ class UserMgr |
111 | 105 | |
112 | 106 | public function getUserInfo() |
113 | 107 | { |
114 | - return $this->amdaClient->getUserInfo($this->user); | |
115 | - } | |
116 | - | |
117 | -/* | |
118 | -* Get Available Missions for a User (groups restriction) | |
119 | -*/ | |
120 | - protected function getAvailableMissionsByUser() | |
121 | - { | |
122 | - $res = $this->amdaClient->getUserAvailableMissions($this->user); | |
123 | - | |
124 | - if (!$res['success']) | |
125 | - return array('local' => array(), 'external' => array()); | |
126 | - | |
127 | - return array('local' => $res['local'], 'external' => $res['external']); | |
108 | + // array("success" => TRUE, | |
109 | + // "login" => $login, | |
110 | + // "name" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("name") : "undefined", | |
111 | + // "first_name" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("first_name") : "undefined", | |
112 | + // "group" => $this->getUserMemberGroups($login), | |
113 | + // "email" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("email") : "undefined", | |
114 | + // "date" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("date") : "undefined", | |
115 | + // "news" => ($theUser->length > 0) ? $theUser->item(0)->getAttribute("news") : "0"); | |
116 | + $info = $this->amdaClient->getUserInfo($this->user); | |
117 | + $wsSize = intval($this->getWsSize()/1024./1024.); | |
118 | + $quota = intval($this->getSpecialSettings()/1024./1024.); | |
119 | + $info['total'] = $quota; | |
120 | + $info['available'] = $quota - $wsSize; | |
121 | + $info['used'] = $wsSize; | |
122 | + | |
123 | + return $info; | |
128 | 124 | } |
129 | 125 | |
130 | 126 | public function createDir() |
131 | 127 | { |
132 | 128 | if (!mkdir($this->userdir, 0755, true)) return false; |
133 | 129 | |
134 | - foreach ($this->userDirs as $key => $val) | |
135 | - { | |
130 | + foreach ($this->userDirs as $key => $val) { | |
136 | 131 | if (!mkdir($this->userdir.$val.'/', 0755, true)) return false; |
137 | 132 | } |
138 | 133 | return true; |
139 | 134 | } |
135 | + | |
136 | + protected function getUserGrps() | |
137 | + { | |
138 | + $info = $this->amdaClient->getUserInfo($this->user); | |
139 | + | |
140 | + if ($info['group'] == '') | |
141 | + return null; | |
142 | + else | |
143 | + return explode(',',$info['group']); | |
144 | + } | |
140 | 145 | |
141 | -/* | |
142 | -* Check if special groups with settings exist and user is from these groups | |
143 | -* Take the first group from user list | |
144 | -*/ | |
146 | + /* | |
147 | + * Check if special groups with settings exist and user is from these groups | |
148 | + * Take the first group from user list | |
149 | + */ | |
145 | 150 | protected function isSpecialGroup() |
146 | 151 | { |
147 | - | |
148 | 152 | $specialGrps = new DomDocument("1.0"); |
149 | 153 | |
150 | 154 | if (!($specialGrps->load(specialGrpsXml))) return null; |
151 | 155 | |
152 | - $info = $this->amdaClient->getUserInfo($this->user); | |
153 | - | |
154 | - $userGrps = explode(',',$info['group']); | |
155 | - | |
156 | 156 | $specialGrpNode = null; |
157 | 157 | |
158 | - foreach ($userGrps as $grp) | |
159 | - { | |
158 | + foreach ($this->userGrps as $grp) { | |
160 | 159 | $specialGrpNode = $specialGrps->getElementById($grp); |
161 | 160 | if ($specialGrpNode) break; |
162 | 161 | } |
... | ... | @@ -164,6 +163,31 @@ class UserMgr |
164 | 163 | return $specialGrpNode; |
165 | 164 | } |
166 | 165 | |
166 | + public function getSpecialSettings() | |
167 | + { | |
168 | + $userSettings = new DomDocument("1.0"); | |
169 | + | |
170 | + if (!file_exists(specialSettingsXml) || !$userSettings->load(specialSettingsXml)) { | |
171 | + return DISK_QUOTA_standard; | |
172 | + } | |
173 | + | |
174 | + $theUser = $userSettings->getElementById($this->user); | |
175 | + if (!$theUser) { | |
176 | + return DISK_QUOTA_standard; | |
177 | + } | |
178 | + | |
179 | + $settings = $theUser->getElementsByTagName("setting"); | |
180 | + if ($settings->length == 0) { | |
181 | + return DISK_QUOTA_standard; | |
182 | + } | |
183 | + | |
184 | + foreach ($settings as $setting) { | |
185 | + if ($setting->getAttribute("name") == 'DISK_QUOTA') | |
186 | + return $setting->getAttribute("value"); | |
187 | + } | |
188 | + | |
189 | + } | |
190 | + | |
167 | 191 | public function setSpecialSettings() |
168 | 192 | { |
169 | 193 | $userSettings = new DomDocument("1.0"); |
... | ... | @@ -185,17 +209,17 @@ class UserMgr |
185 | 209 | } |
186 | 210 | |
187 | 211 | foreach ($settings as $setting) { |
188 | - $key = $setting->getAttribute("name"); | |
189 | - $value = $setting->getAttribute("value"); | |
190 | - $isSetting = $setting->hasAttribute("isSetting"); | |
191 | - if ($isSetting) { | |
192 | - ini_set("$key",$value); | |
193 | - } | |
194 | - else { | |
195 | - // Attention !!! CONSTANT cannot be redefined | |
196 | - define("$key",$value); | |
197 | - } | |
198 | - } | |
212 | + $key = $setting->getAttribute("name"); | |
213 | + $value = $setting->getAttribute("value"); | |
214 | + $isSetting = $setting->hasAttribute("isSetting"); | |
215 | + if ($isSetting) { | |
216 | + ini_set("$key",$value); | |
217 | + } | |
218 | + else { | |
219 | + // Attention !!! CONSTANT cannot be redefined | |
220 | + define("$key",$value); | |
221 | + } | |
222 | + } | |
199 | 223 | } |
200 | 224 | /* |
201 | 225 | * Totally replace IMPEX staff in user remote tree |
... | ... | @@ -292,9 +316,7 @@ class UserMgr |
292 | 316 | protected function makeRemoteTree() |
293 | 317 | { |
294 | 318 | $remoteBases = new DomDocument("1.0"); |
295 | - $availableMis = $this->userMissions['external']; | |
296 | - if (!isset($availableMis)) | |
297 | - $availableMis = array(); | |
319 | + | |
298 | 320 | unlink(USERWSDIR.'RemoteParams.xml'); |
299 | 321 | if (file_exists(USERWSDIR.'RemoteParams.xml')) |
300 | 322 | { |
... | ... | @@ -313,9 +335,8 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
313 | 335 | { |
314 | 336 | $baseId = $base->getAttribute('xml:id'); |
315 | 337 | if ($base->getAttribute('isSimulation')) continue; |
316 | - | |
317 | - $notAvailable = (array_search($baseId,$availableMis) === FALSE); | |
318 | - $base->setAttribute('available',!$notAvailable); | |
338 | + | |
339 | + $base->setAttribute('available',true); | |
319 | 340 | |
320 | 341 | // Update Info on External Data Sets in UserTree.xml for everything except IMPEX |
321 | 342 | $dataSets = $base->getElementsByTagName("dataset"); |
... | ... | @@ -377,8 +398,6 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
377 | 398 | $baseId = $base->getAttribute('xml:id'); |
378 | 399 | $paramMgr->baseId = $baseId; |
379 | 400 | |
380 | - $notAvailable = (array_search($baseId,$availableMis) === FALSE); | |
381 | - | |
382 | 401 | // no data base description ; skip this data base |
383 | 402 | if (!file_exists(RemoteData.$baseId.'/base.xml')) continue; |
384 | 403 | |
... | ... | @@ -433,7 +452,7 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
433 | 452 | |
434 | 453 | $center->setAttribute('name', $base->getAttribute('name')); |
435 | 454 | $center->setAttribute('desc', $base->getAttribute('desc')); |
436 | - $center->setAttribute('available',!$notAvailable); | |
455 | + $center->setAttribute('available',true); | |
437 | 456 | $BASE->appendChild($center); |
438 | 457 | } |
439 | 458 | $paramMgr->xmlDom->appendChild($BASE); |
... | ... | @@ -498,18 +517,15 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
498 | 517 | |
499 | 518 | public function setPath() |
500 | 519 | { |
501 | - if (isset($_GET['sessionID'])) | |
502 | - { | |
520 | + if (isset($_GET['sessionID'])) { | |
503 | 521 | $this->user = $_GET['sessionID']; |
504 | 522 | $this->userdir = USERPATH."/".$this->user."/"; |
505 | 523 | } |
506 | 524 | // for testing purposes |
507 | - else if (defined('TRANSFERUSER')) | |
508 | - { | |
525 | + else if (defined('TRANSFERUSER')) { | |
509 | 526 | $this->userdir = BASE_PATH."test/".TRANSFERUSER."/"; |
510 | 527 | } |
511 | - else if (isset($this->user)) | |
512 | - { | |
528 | + else if (isset($this->user)) { | |
513 | 529 | $this->userdir = USERPATH."/".$this->user."/"; |
514 | 530 | } |
515 | 531 | |
... | ... | @@ -517,8 +533,7 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
517 | 533 | |
518 | 534 | define ("USERDIR", "$usrdir/"); |
519 | 535 | |
520 | - foreach ($this->userDirs as $key => $val) | |
521 | - { | |
536 | + foreach ($this->userDirs as $key => $val) { | |
522 | 537 | $dir = $usrdir.$val; |
523 | 538 | define("$key","$dir/"); |
524 | 539 | } |
... | ... | @@ -551,17 +566,14 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
551 | 566 | |
552 | 567 | $this->userdir = USERPATH."/".$this->user."/"; |
553 | 568 | |
554 | - if (!is_dir($this->userdir)) | |
555 | - { | |
556 | - if (!$this->createDir()) | |
557 | - { | |
569 | + if (!is_dir($this->userdir)) { | |
570 | + if (!$this->createDir()) { | |
558 | 571 | die("Login for ".$this->user." failed: Can't create WS dirs"); |
559 | 572 | } |
560 | 573 | $this->isFirst = true; |
561 | 574 | } |
562 | 575 | |
563 | - if (file_exists($this->userdir.'newLogin')) | |
564 | - { | |
576 | + if (file_exists($this->userdir.'newLogin')) { | |
565 | 577 | copy($this->userdir.'newLogin',$this->userdir.'lastLogin'); |
566 | 578 | $dt = filemtime($this->userdir.'newLogin'); |
567 | 579 | touch($this->userdir.'lastLogin', $dt); |
... | ... | @@ -587,18 +599,17 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
587 | 599 | touch($this->userdir.'newLogin'); |
588 | 600 | |
589 | 601 | $this->setPath(); |
590 | - // $this->userMissions = $this->getAvailableMissionsByUser(); | |
602 | + | |
603 | + $this->userGrps = $this->getUserGrps(); | |
604 | + | |
605 | + if (!$this->makeLocalTree()) | |
606 | + die("Login for ".$this->user." failed: Can't make LocalParams.xml");; | |
591 | 607 | |
592 | - if (file_exists(USERWSDIR.'LocalParams.xml')) | |
593 | - unlink(USERWSDIR.'LocalParams.xml'); | |
594 | - // if (!file_exists(USERWSDIR.'LocalParams.xml')) | |
595 | - symlink(DATAPATH.'/LocalData/LocalParams.xml', USERWSDIR.'LocalParams.xml'); | |
596 | - | |
597 | 608 | $ok = $this->makeRemoteTree(); |
598 | 609 | |
599 | 610 | if (!file_exists(USERWSDIR.'Request.xml')) $reqMgr = new RequestMgr(); |
600 | 611 | if (!file_exists(USERWSDIR.'Tt.xml')) $ttMgr = new TimeTableMgr(); |
601 | - if (!file_exists(USERWSDIR.'Alias.xml'))$ttMgr = new AliasMgr(); | |
612 | + if (!file_exists(USERWSDIR.'Alias.xml')) $ttMgr = new AliasMgr(); | |
602 | 613 | |
603 | 614 | //TODO sessionID = user + WSname |
604 | 615 | $sessionID = $this->user; |
... | ... | @@ -611,53 +622,85 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
611 | 622 | /* |
612 | 623 | * Special groups are defined in the generic_data/SpecialSettings/Groups.xml |
613 | 624 | */ |
614 | - // $specialGroup = $this->isSpecialGroup(); | |
615 | - $specialGroup = false; | |
616 | - // Special Info for special groups | |
617 | - if ($specialGroup) | |
618 | - { | |
619 | - // Special Settings for special groups - first visit just copying | |
620 | - if ($this->isFirst) | |
621 | - { | |
622 | - $grp = $specialGroup->getAttribute('xml:id'); | |
623 | - $tags = $specialGroup->getElementsByTagName('folder'); | |
624 | - | |
625 | - foreach ($tags as $tag) | |
626 | - { | |
627 | - $folder = $tag->getAttribute('name'); | |
628 | - foreach (glob(SpecialSettingsDir.$grp."/".$folder."/*") as $file) | |
629 | - { | |
630 | - copy($file, $this->userdir.$folder."/".basename($file)); | |
631 | - } | |
625 | + if ($this->userGrps) { | |
626 | + // $specialGroup = $this->isSpecialGroup(); | |
627 | + $specialGroup = false; | |
628 | + // Special Info for special groups | |
629 | + if ($specialGroup) { | |
630 | + // Special Settings for special groups - first visit just copying | |
631 | + if ($this->isFirst) { | |
632 | + $grp = $specialGroup->getAttribute('xml:id'); | |
633 | + $tags = $specialGroup->getElementsByTagName('folder'); | |
634 | + | |
635 | + foreach ($tags as $tag) { | |
636 | + $folder = $tag->getAttribute('name'); | |
637 | + | |
638 | + foreach (glob(SpecialSettingsDir.$grp."/".$folder."/*") as $file) { | |
639 | + copy($file, $this->userdir.$folder."/".basename($file)); | |
640 | + } | |
641 | + } | |
642 | + // mark to show help information | |
643 | + touch($this->userdir."$grp"."Help"); | |
632 | 644 | } |
633 | - // mark to show help information | |
634 | - touch($this->userdir."$grp"."Help"); | |
645 | + // add requests | |
646 | + else { } | |
647 | + $grpName = $specialGroup->getAttribute('xml:id'); | |
648 | + $helpName = "$grpName"."Help"; | |
649 | + | |
650 | + if (file_exists(HELPPATH.$helpName) && file_exists($this->userdir.$helpName)) | |
651 | + $this->isSpecialInfo = $helpName; | |
635 | 652 | } |
636 | - // add requests | |
637 | - else { } | |
638 | - $grpName = $specialGroup->getAttribute('xml:id'); | |
639 | - $helpName = "$grpName"."Help"; | |
640 | - | |
641 | - if (file_exists(HELPPATH.$helpName) && file_exists($this->userdir.$helpName)) | |
642 | - $this->isSpecialInfo = $helpName; | |
643 | - | |
644 | 653 | } |
645 | 654 | return $sessionID; |
646 | 655 | } |
647 | 656 | |
657 | + protected function makeLocalTree() | |
658 | + { | |
659 | + if (file_exists(USERWSDIR.'LocalParams.xml')) | |
660 | + unlink(USERWSDIR.'LocalParams.xml'); | |
661 | + | |
662 | + if (!copy(DATAPATH.'/LocalData/LocalParams.xml', USERWSDIR.'LocalParams.xml')) | |
663 | + die("Login for ".$this->user." failed: Can't copy LocalParams.xml"); | |
664 | + | |
665 | + if ($this->userGrps) | |
666 | + return $this->updateTreeForGrps(USERWSDIR.'LocalParams.xml'); | |
667 | + | |
668 | + return true; | |
669 | + } | |
670 | + | |
671 | + protected function updateTreeForGrps($file) | |
672 | + { | |
673 | + $xml = new DomDocument("1.0"); | |
674 | + | |
675 | + if(!$xml->load($file)) | |
676 | + die("Login for ".$this->user." failed: Can't load LocalParams.xml"); | |
677 | + | |
678 | + $xp = new domxpath($xml); | |
679 | + | |
680 | + foreach ($this->userGrps as $grp) { | |
681 | + $nodes = $xp->query("//*[@group='".$grp."']"); | |
682 | + | |
683 | + if ($nodes->length > 0) | |
684 | + foreach ($nodes as $node) { | |
685 | + $node->removeAttribute('group'); | |
686 | + if ($node->hasAttribute('restriction')) | |
687 | + $node->removeAttribute('restriction'); | |
688 | + } | |
689 | + } | |
690 | + | |
691 | + return $xml->save($file); | |
692 | + } | |
693 | + | |
648 | 694 | public function dirSize($dir) |
649 | 695 | { |
650 | 696 | $handle = opendir($dir); |
651 | 697 | |
652 | 698 | $mas = 0; |
653 | - while ($file = readdir($handle)) | |
654 | - { | |
655 | - if ($file != '..' && $file != '.' && !is_dir($dir.'/'.$file)) | |
656 | - { | |
699 | + while ($file = readdir($handle)) { | |
700 | + if ($file != '..' && $file != '.' && !is_dir($dir.'/'.$file)) { | |
657 | 701 | $mas += filesize($dir.'/'.$file); |
658 | 702 | } |
659 | - else if (is_dir($dir.'/'.$file) && $file != '..' && $file != '.') | |
660 | - { | |
703 | + else if (is_dir($dir.'/'.$file) && $file != '..' && $file != '.') { | |
661 | 704 | $mas += $this->dirSize($dir.'/'.$file); |
662 | 705 | } |
663 | 706 | } |
... | ... | @@ -674,7 +717,7 @@ unlink(USERWSDIR.'RemoteParams.xml'); |
674 | 717 | return $wsSize; |
675 | 718 | } |
676 | 719 | |
677 | -// http://www.ilovejackdaniels.com/php/email-address-validation/ | |
720 | + // http://www.ilovejackdaniels.com/php/email-address-validation/ | |
678 | 721 | public function check_email_address($email) |
679 | 722 | { |
680 | 723 | // First, we check that there's one @ symbol, and that the lengths are right | ... | ... |
php/impex_config.php deleted
... | ... | @@ -1,33 +0,0 @@ |
1 | -<?php | |
2 | - /** | |
3 | - * @file impex_config.php | |
4 | - * @version $Id: impex_config.php 2912 2015-05-19 10:29:26Z elena $ | |
5 | - * | |
6 | - */ | |
7 | - // Simulations DB | |
8 | - define('wsdl_LATMOS','http://impex.latmos.ipsl.fr/Methods_LATMOS.wsdl'); | |
9 | - //define('wsdl_LATMOS','http://134.157.176.122/Methods_LATMOS.wsdl'); | |
10 | - define('wsdl_SINP','http://smdc.sinp.msu.ru/impex/SINP_methods.wsdl'); | |
11 | - define('wsdl_FMI','http://impex-fp7.fmi.fi/ws/Methods_FMI.wsdl'); | |
12 | - define('wsdl_LESIA', 'http://maser.obspm.fr/IMPExWS/Methods_LESIA-Mag.wsdl'); | |
13 | - define('wsdl_CLWEB', 'http://clweb.cesr.fr/Methods_CLWEB.wsdl'); | |
14 | - | |
15 | - define('tree_LATMOS','http://impex.latmos.ipsl.fr/tree.xml'); | |
16 | - define('tree_LESIA','http://maser.obspm.fr/IMPExWS/tree_Mag.xml'); | |
17 | - define('tree_SINP','http://smdc.sinp.msu.ru/impex/SINP_tree.xml'); | |
18 | - define('tree_FMI_HYBRID','http://impex-fp7.fmi.fi/ws/Tree_FMI_HYB.xml'); | |
19 | - define('tree_FMI_GUMICS','http://impex-fp7.fmi.fi/ws/Tree_FMI_GUMICS.xml'); | |
20 | - define('tree_CCMC','http://apus.cesr.fr/AMDA-IMPEX/public/trees/Tree_CCMC_chablon5.xml'); | |
21 | - define('tree_CLWEB','CLWeb/base.xml'); | |
22 | - | |
23 | - define("baseDirLATMOS", BASE_PATH."generic_data/RemoteData/LATMOS/base.xml"); | |
24 | - define("baseDirSINP", BASE_PATH."generic_data/RemoteData/SINP/base.xml"); | |
25 | - define("baseDirCLWEB", BASE_PATH."generic_data/RemoteData/CLWeb/base.xml"); | |
26 | - define("baseDirFMI_HYB", BASE_PATH."generic_data/RemoteData/FMI_HYBRID/base.xml"); | |
27 | - define("baseDirFMI_GUMICS", BASE_PATH."generic_data/RemoteData/FMI_GUMICS/base.xml"); | |
28 | - define("baseDirLESIA", BASE_PATH."generic_data/RemoteData/LESIA/base.xml"); | |
29 | - define("baseDirCCMC", BASE_PATH."generic_data/RemoteData/CCMC/base.xml"); | |
30 | - | |
31 | - define("tmplGUMICS", BASE_PATH."generic_data/SimuTemplate/templateGUMICS.xml"); | |
32 | - define("DELTA", 120); // minumum file size in secs | |
33 | -?> |