Commit e57cb0251628b7f6eaa1a24ceb1c3268f5c3af98

Authored by Benjamin Renard
1 parent 0bda97f3

Fix most of errors logged by apache

php/classes/AmdaAction.php
... ... @@ -74,14 +74,24 @@ class AmdaAction
74 74 return $this->getUrlDirs($url);
75 75 }
76 76  
77   - if ($obj->baseId) $remoteBase = true;
  77 + if (isset($obj->baseId)) $remoteBase = true;
78 78  
79 79 if ($node == 'root' && $remoteBase) $node = $obj->baseId;
80 80  
81 81 if ($node == 'root' && !$remoteBase)
82 82 {
83   - $json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
84   - $childrenToReturn = $json_o->nodes;
  83 + if (file_exists(DATAPATH.$nodeType.'.json')) {
  84 + $json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
  85 + if (empty($json_o)) {
  86 + $childrenToReturn = array();
  87 + }
  88 + else {
  89 + $childrenToReturn = $json_o->nodes;
  90 + }
  91 + }
  92 + else {
  93 + $childrenToReturn = array();
  94 + }
85 95 }
86 96 else
87 97 {
... ... @@ -110,12 +120,12 @@ class AmdaAction
110 120 $nodeType = 'remoteParam';
111 121 }
112 122  
113   - $Dom->load($xmlName);
  123 + @$Dom->load($xmlName);
114 124  
115 125 if ($node == "myRemoteSimuData-treeRootNode") $node = "myRemoteData-treeRootNode";
116 126  
117 127 $nodeToOpen = $Dom->getElementById($node);
118   - $children = $nodeToOpen->childNodes;
  128 + $children = empty($nodeToOpen->childNodes) ? array() : $nodeToOpen->childNodes;
119 129  
120 130 foreach ($children as $child)
121 131 if ($child->nodeType == XML_ELEMENT_NODE)
... ... @@ -144,6 +154,7 @@ class AmdaAction
144 154 $isAddable = false;
145 155 $isSimulation = false;
146 156 $rank = null;
  157 + $skip = FALSE;
147 158  
148 159 switch ($nodeType)
149 160 {
... ... @@ -208,6 +219,7 @@ class AmdaAction
208 219 $needsArgs = false;
209 220 $isSpectra = false;
210 221 $isStack = false;
  222 + $not_yet = false;
211 223  
212 224 if ($child->hasAttribute('desc'))
213 225 {
... ... @@ -470,12 +482,11 @@ class AmdaAction
470 482 }
471 483 else
472 484 {
  485 + $restricted = FALSE;
473 486 // if ($child->tagName == 'dataCenter')
474 487 // {
475 488 // $restricted = ($child->getAttribute('available') != "1");
476 489 // }
477   -// else
478   -// $restricted = false;
479 490 //
480 491 if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP')
481 492 $restricted = FALSE;
... ... @@ -562,7 +573,7 @@ class AmdaAction
562 573 }
563 574 }
564 575 // if $childrenToReturn we have to return []
565   - if ($childrenToReturn == null)
  576 + if (empty($childrenToReturn))
566 577 {
567 578 $childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
568 579 }
... ... @@ -847,6 +858,7 @@ class AmdaAction
847 858 public function getJobs()
848 859 {
849 860 require_once(INTEGRATION_SRC_DIR."RequestManager.php");
  861 + $obj = (object) array();
850 862 return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
851 863 }
852 864  
... ... @@ -910,7 +922,7 @@ class AmdaAction
910 922  
911 923 try
912 924 {
913   - $res = $requestManager->runIHMRequest($this->user, $res['userHost'], $function, $obj);
  925 + $res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj);
914 926 } catch (Exception $e)
915 927 {
916 928 return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
... ... @@ -1049,15 +1061,15 @@ class AmdaAction
1049 1061  
1050 1062 public function readTTCacheIntervals($o)
1051 1063 {
1052   - if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
  1064 + if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) $cacheMgr = new CatalogCacheMgr();
1053 1065 else $cacheMgr = new TimeTableCacheMgr();
1054 1066  
1055   - return $cacheMgr->getIntervals($o->start,$o->limit,$o->sort,$o->filter);
  1067 + return $cacheMgr->getIntervals($o->start,$o->limit,isset($o->sort) ? $o->sort : NULL, isset($o->filter) ? $o->filter : NULL);
1056 1068 }
1057 1069  
1058 1070 public function readIntervalsForChart($o)
1059 1071 {
1060   - if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') {
  1072 + if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) {
1061 1073  
1062 1074 if ($o->fromPlugin && $o->id == 'cacheCat') {
1063 1075 $objMgr = new CatalogCacheMgr();
... ... @@ -1187,7 +1199,7 @@ class AmdaAction
1187 1199 /*
1188 1200 * Filters
1189 1201 */
1190   - public function loadFilterList($o)
  1202 + public function loadFilterList()
1191 1203 {
1192 1204 $filtersMgr = new FiltersMgr();
1193 1205 $res = $filtersMgr->loadList();
... ... @@ -1321,6 +1333,7 @@ class AmdaAction
1321 1333 $impexParamMgr = new ImpexParamManager();
1322 1334 $impexParamMgr->deleteImpexStaff();
1323 1335  
  1336 + $obj = (object) array();
1324 1337 return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSCLEAN);
1325 1338 }
1326 1339  
... ...
php/classes/FilterRes.php
... ... @@ -42,6 +42,7 @@
42 42 return $this->getAll();
43 43  
44 44 $ops = array();
  45 + $cond_res = array();
45 46 for ($i = 0 ; $i < count($filter); $i++)
46 47 {
47 48 $cond = $filter[$i];
... ... @@ -72,4 +73,4 @@
72 73 return $cond_res[0];
73 74 }
74 75 }
75   -?>
76 76 \ No newline at end of file
  77 +?>
... ...
php/classes/FilterResParam.php
... ... @@ -13,7 +13,7 @@
13 13 {
14 14 $this->localXmlName = USERWSDIR."LocalParams.xml";
15 15 $this->localXml = new DomDocument("1.0");
16   - $this->localXml->load($this->localXmlName);
  16 + @$this->localXml->load($this->localXmlName);
17 17 $this->rootElement = $this->localXml->documentElement;
18 18  
19 19 $this->xp = new domxpath($this->localXml);
... ... @@ -107,7 +107,7 @@
107 107 if (strlen($targetId) > strlen($value))
108 108 $ok = ((substr($targetId,0,strlen($value)) == $value) && ($targetId[strlen($value)]=='.'));
109 109  
110   - $id = $datsetId;
  110 + $id = $datasetId;
111 111 $chain = $datasetId;
112 112 $node = $datasets->item($k);
113 113  
... ... @@ -319,7 +319,7 @@
319 319  
320 320 $datasetId = $datasets->item($k)->getAttribute('xml:id');
321 321  
322   - $id = $datsetId;
  322 + $id = $datasetId;
323 323 $chain = $datasetId;
324 324 $node = $datasets->item($k);
325 325  
... ... @@ -361,4 +361,4 @@
361 361 }
362 362 }
363 363  
364   -?>
365 364 \ No newline at end of file
  365 +?>
... ...
php/classes/FilterResSimu.php
... ... @@ -15,8 +15,10 @@
15 15 {
16 16 $this->simXmlName = $basePath;
17 17 $this->simXml = new DomDocument("1.0");
18   - $this->simXml->load($this->simXmlName);
19   - $this->simRootEl = $this->simXml->documentElement;
  18 + if (file_exists($this->simXmlName)) {
  19 + $this->simXml->load($this->simXmlName);
  20 + $this->simRootEl = $this->simXml->documentElement;
  21 + }
20 22 $this->simXP = new domxpath($this->simXml);
21 23 $this->centerID = $centerID;
22 24 }
... ... @@ -251,6 +253,7 @@
251 253 if ($isEmptyFilter)
252 254 return $this->getAll();
253 255 $ops = array();
  256 + $cond_res = array();
254 257 for ($i = 0 ; $i < count($filter); $i++)
255 258 {
256 259 $cond = $filter[$i];
... ... @@ -280,4 +283,4 @@
280 283 return $cond_res[0];
281 284 }
282 285 }
283   -?>
284 286 \ No newline at end of file
  287 +?>
... ...
php/classes/FiltersMgr.php
... ... @@ -6,7 +6,7 @@
6 6 protected $rootElement;
7 7 protected $flyQuery;
8 8  
9   - function __construct($flyQuery)
  9 + function __construct($flyQuery = NULL)
10 10 {
11 11 $this->flyQuery = isset($flyQuery) && $flyQuery;
12 12  
... ... @@ -293,7 +293,7 @@
293 293 return false;
294 294 }
295 295  
296   - function getResultFromFilterArray($filter_array)
  296 + function getResultFromFilterArray($filter_array, $isEmptyFilter)
297 297 {
298 298 $result = array();
299 299 foreach ($filter_array as $key => $sub_filter)
... ... @@ -367,7 +367,7 @@
367 367 'value' => $cond->getAttribute('value')));
368 368 }
369 369  
370   - $result = $this->getResultFromFilterArray($filter_array);
  370 + $result = $this->getResultFromFilterArray($filter_array, $isEmptyFilter);
371 371  
372 372 $result['id'] = $crtFilter->getAttribute('id');
373 373 if (($result['id'] == 0) && $isFullEmptyFilter)
... ... @@ -396,4 +396,4 @@
396 396 return false;
397 397 }
398 398 }
399   -?>
400 399 \ No newline at end of file
  400 +?>
... ...
php/classes/IntervalCacheObject.php
... ... @@ -8,7 +8,7 @@ class IntervalCacheObject
8 8 protected $isNew = false;
9 9 protected $isModified = false;
10 10  
11   - function __construct($id, $index) {
  11 + function __construct($id, $index = -1) {
12 12 $this->id = $id;
13 13 $this->index = $index;
14 14 }
... ... @@ -111,4 +111,4 @@ class IntervalCacheObject
111 111 echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".$this->start.", stop = ".$this->stop.", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL;
112 112 }
113 113 }
114   -?>
115 114 \ No newline at end of file
  115 +?>
... ...
php/classes/RequestMgr.php
... ... @@ -249,7 +249,7 @@ class RequestMgr extends AmdaObjectMgr
249 249 if ($param->template_args->url_XYZ) $params[] = $param->template_args->url_XYZ;
250 250 }
251 251 }
252   - if (count($params) > 0)
  252 + if (!empty($params))
253 253 {
254 254 $argsTab['param'] = array_unique($params);
255 255 $argsTab['startTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->startDate;
... ...
php/classes/TimeTableMgr.php
... ... @@ -22,7 +22,7 @@ function timeFormat($myString)
22 22  
23 23 class TimeTableMgr extends AmdaObjectMgr
24 24 {
25   - function __construct($user, $sharedObject = FALSE)
  25 + function __construct($user = NULL, $sharedObject = FALSE)
26 26 {
27 27 parent::__construct('Tt.xml');
28 28 $this->contentRootId = 'timeTable-treeRootNode';
... ...
php/classes/UserMgr.php
... ... @@ -28,7 +28,7 @@ class UserMgr
28 28 public $isNewInfo = false;
29 29 public $isSpecialInfo = null;
30 30  
31   - function __construct($username,$password,$sessionID)
  31 + function __construct($username = NULL, $password = NULL, $sessionID = NULL)
32 32 {
33 33 // if magic quotes is on, stripslashes
34 34 if(get_magic_quotes_gpc())
... ... @@ -165,10 +165,10 @@ class UserMgr
165 165 }
166 166  
167 167 public function setSpecialSettings()
168   - {
  168 + {
169 169 $userSettings = new DomDocument("1.0");
170 170  
171   - if (!$userSettings->load(specialSettingsXml)) {
  171 + if (!file_exists(specialSettingsXml) || !$userSettings->load(specialSettingsXml)) {
172 172 define("DISK_QUOTA", DISK_QUOTA_standard);
173 173 return;
174 174 }
... ... @@ -293,6 +293,8 @@ class UserMgr
293 293 {
294 294 $remoteBases = new DomDocument("1.0");
295 295 $availableMis = $this->userMissions['external'];
  296 + if (!isset($availableMis))
  297 + $availableMis = array();
296 298 unlink(USERWSDIR.'RemoteParams.xml');
297 299 if (file_exists(USERWSDIR.'RemoteParams.xml'))
298 300 {
... ... @@ -381,7 +383,7 @@ unlink(USERWSDIR.&#39;RemoteParams.xml&#39;);
381 383 if (!file_exists(RemoteData.$baseId.'/base.xml')) continue;
382 384  
383 385 // can't read base.xml ; skip this data base
384   - if (!$baseXml->load(RemoteData.$baseId.'/base.xml')) continue;
  386 + if (!@$baseXml->load(RemoteData.$baseId.'/base.xml')) continue;
385 387  
386 388 // Some small & well known data centers are included by default:
387 389 // Each VI structure and VI (dataset) description at DD Server for them should exist
... ... @@ -646,7 +648,8 @@ unlink(USERWSDIR.&#39;RemoteParams.xml&#39;);
646 648 public function dirSize($dir)
647 649 {
648 650 $handle = opendir($dir);
649   -
  651 +
  652 + $mas = 0;
650 653 while ($file = readdir($handle))
651 654 {
652 655 if ($file != '..' && $file != '.' && !is_dir($dir.'/'.$file))
... ...
php/classes/VOTableMgr.php
... ... @@ -42,11 +42,21 @@ class VOTableMgr {
42 42 'ignore_errors' => true
43 43 )
44 44 );
  45 +
  46 + // BRE - Add proxy host if exists
  47 + if (defined('HTTP_PROXY_HOST')) {
  48 + $options['http']['proxy'] = 'tcp://'.HTTP_PROXY_HOST;
  49 + $options['http']['request_fulluri'] = TRUE;
  50 + if (defined('HTTP_PROXY_USER')) {
  51 + $options['http']['header'] = "Proxy-Authorization: Basic ".base64_encode(HTTP_PROXY_USER);
  52 + }
  53 + }
  54 +
45 55 $context = stream_context_create($options);
46 56 libxml_set_streams_context($context);
47 57 $this->xml = new DomDocument();
48 58  
49   - if (!$this->xml->load($fileName)) {
  59 + if (!@$this->xml->load($fileName)) {
50 60 $this->votable_error = 'Can not load xml file.';
51 61 return false;
52 62 }
... ...
php/router.php
... ... @@ -76,7 +76,7 @@
76 76 * Main
77 77 */
78 78  
79   - define('log',fopen('log','w'));
  79 +// define('log',fopen('log','w'));
80 80 $isForm = false;
81 81 $isUpload = false;
82 82  
... ... @@ -135,5 +135,5 @@
135 135 echo json_encode($response);
136 136 }
137 137  
138   - fclose(log);
  138 +// fclose(log);
139 139 ?>
... ...