From e57cb0251628b7f6eaa1a24ceb1c3268f5c3af98 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 18 Jan 2018 11:57:16 +0100 Subject: [PATCH] Fix most of errors logged by apache --- php/classes/AmdaAction.php | 39 ++++++++++++++++++++++++++------------- php/classes/FilterRes.php | 3 ++- php/classes/FilterResParam.php | 8 ++++---- php/classes/FilterResSimu.php | 9 ++++++--- php/classes/FiltersMgr.php | 8 ++++---- php/classes/IntervalCacheObject.php | 4 ++-- php/classes/RequestMgr.php | 2 +- php/classes/TimeTableMgr.php | 2 +- php/classes/UserMgr.php | 13 ++++++++----- php/classes/VOTableMgr.php | 12 +++++++++++- php/router.php | 4 ++-- 11 files changed, 67 insertions(+), 37 deletions(-) diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 66963cc..491410d 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -74,14 +74,24 @@ class AmdaAction return $this->getUrlDirs($url); } - if ($obj->baseId) $remoteBase = true; + if (isset($obj->baseId)) $remoteBase = true; if ($node == 'root' && $remoteBase) $node = $obj->baseId; if ($node == 'root' && !$remoteBase) { - $json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json')); - $childrenToReturn = $json_o->nodes; + if (file_exists(DATAPATH.$nodeType.'.json')) { + $json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json')); + if (empty($json_o)) { + $childrenToReturn = array(); + } + else { + $childrenToReturn = $json_o->nodes; + } + } + else { + $childrenToReturn = array(); + } } else { @@ -110,12 +120,12 @@ class AmdaAction $nodeType = 'remoteParam'; } - $Dom->load($xmlName); + @$Dom->load($xmlName); if ($node == "myRemoteSimuData-treeRootNode") $node = "myRemoteData-treeRootNode"; $nodeToOpen = $Dom->getElementById($node); - $children = $nodeToOpen->childNodes; + $children = empty($nodeToOpen->childNodes) ? array() : $nodeToOpen->childNodes; foreach ($children as $child) if ($child->nodeType == XML_ELEMENT_NODE) @@ -144,6 +154,7 @@ class AmdaAction $isAddable = false; $isSimulation = false; $rank = null; + $skip = FALSE; switch ($nodeType) { @@ -208,6 +219,7 @@ class AmdaAction $needsArgs = false; $isSpectra = false; $isStack = false; + $not_yet = false; if ($child->hasAttribute('desc')) { @@ -470,12 +482,11 @@ class AmdaAction } else { + $restricted = FALSE; // if ($child->tagName == 'dataCenter') // { // $restricted = ($child->getAttribute('available') != "1"); // } -// else -// $restricted = false; // if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP') $restricted = FALSE; @@ -562,7 +573,7 @@ class AmdaAction } } // if $childrenToReturn we have to return [] - if ($childrenToReturn == null) + if (empty($childrenToReturn)) { $childrenToReturn = array('nodeType' => $nodeType, 'text' => null); } @@ -847,6 +858,7 @@ class AmdaAction public function getJobs() { require_once(INTEGRATION_SRC_DIR."RequestManager.php"); + $obj = (object) array(); return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO); } @@ -910,7 +922,7 @@ class AmdaAction try { - $res = $requestManager->runIHMRequest($this->user, $res['userHost'], $function, $obj); + $res = $requestManager->runIHMRequest($this->user, !empty($res['userHost']) ? $res['userHost'] : NULL, $function, $obj); } catch (Exception $e) { return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage()); @@ -1049,15 +1061,15 @@ class AmdaAction public function readTTCacheIntervals($o) { - if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr(); + if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) $cacheMgr = new CatalogCacheMgr(); else $cacheMgr = new TimeTableCacheMgr(); - return $cacheMgr->getIntervals($o->start,$o->limit,$o->sort,$o->filter); + return $cacheMgr->getIntervals($o->start,$o->limit,isset($o->sort) ? $o->sort : NULL, isset($o->filter) ? $o->filter : NULL); } public function readIntervalsForChart($o) { - if ($o->typeTT == 'catalog' || $type == 'sharedcatalog') { + if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) { if ($o->fromPlugin && $o->id == 'cacheCat') { $objMgr = new CatalogCacheMgr(); @@ -1187,7 +1199,7 @@ class AmdaAction /* * Filters */ - public function loadFilterList($o) + public function loadFilterList() { $filtersMgr = new FiltersMgr(); $res = $filtersMgr->loadList(); @@ -1321,6 +1333,7 @@ class AmdaAction $impexParamMgr = new ImpexParamManager(); $impexParamMgr->deleteImpexStaff(); + $obj = (object) array(); return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSCLEAN); } diff --git a/php/classes/FilterRes.php b/php/classes/FilterRes.php index bd08bb1..76d05df 100644 --- a/php/classes/FilterRes.php +++ b/php/classes/FilterRes.php @@ -42,6 +42,7 @@ return $this->getAll(); $ops = array(); + $cond_res = array(); for ($i = 0 ; $i < count($filter); $i++) { $cond = $filter[$i]; @@ -72,4 +73,4 @@ return $cond_res[0]; } } -?> \ No newline at end of file +?> diff --git a/php/classes/FilterResParam.php b/php/classes/FilterResParam.php index 7570747..8203247 100644 --- a/php/classes/FilterResParam.php +++ b/php/classes/FilterResParam.php @@ -13,7 +13,7 @@ { $this->localXmlName = USERWSDIR."LocalParams.xml"; $this->localXml = new DomDocument("1.0"); - $this->localXml->load($this->localXmlName); + @$this->localXml->load($this->localXmlName); $this->rootElement = $this->localXml->documentElement; $this->xp = new domxpath($this->localXml); @@ -107,7 +107,7 @@ if (strlen($targetId) > strlen($value)) $ok = ((substr($targetId,0,strlen($value)) == $value) && ($targetId[strlen($value)]=='.')); - $id = $datsetId; + $id = $datasetId; $chain = $datasetId; $node = $datasets->item($k); @@ -319,7 +319,7 @@ $datasetId = $datasets->item($k)->getAttribute('xml:id'); - $id = $datsetId; + $id = $datasetId; $chain = $datasetId; $node = $datasets->item($k); @@ -361,4 +361,4 @@ } } -?> \ No newline at end of file +?> diff --git a/php/classes/FilterResSimu.php b/php/classes/FilterResSimu.php index 03c1585..383e34d 100644 --- a/php/classes/FilterResSimu.php +++ b/php/classes/FilterResSimu.php @@ -15,8 +15,10 @@ { $this->simXmlName = $basePath; $this->simXml = new DomDocument("1.0"); - $this->simXml->load($this->simXmlName); - $this->simRootEl = $this->simXml->documentElement; + if (file_exists($this->simXmlName)) { + $this->simXml->load($this->simXmlName); + $this->simRootEl = $this->simXml->documentElement; + } $this->simXP = new domxpath($this->simXml); $this->centerID = $centerID; } @@ -251,6 +253,7 @@ if ($isEmptyFilter) return $this->getAll(); $ops = array(); + $cond_res = array(); for ($i = 0 ; $i < count($filter); $i++) { $cond = $filter[$i]; @@ -280,4 +283,4 @@ return $cond_res[0]; } } -?> \ No newline at end of file +?> diff --git a/php/classes/FiltersMgr.php b/php/classes/FiltersMgr.php index 6b10129..5559dee 100644 --- a/php/classes/FiltersMgr.php +++ b/php/classes/FiltersMgr.php @@ -6,7 +6,7 @@ protected $rootElement; protected $flyQuery; - function __construct($flyQuery) + function __construct($flyQuery = NULL) { $this->flyQuery = isset($flyQuery) && $flyQuery; @@ -293,7 +293,7 @@ return false; } - function getResultFromFilterArray($filter_array) + function getResultFromFilterArray($filter_array, $isEmptyFilter) { $result = array(); foreach ($filter_array as $key => $sub_filter) @@ -367,7 +367,7 @@ 'value' => $cond->getAttribute('value'))); } - $result = $this->getResultFromFilterArray($filter_array); + $result = $this->getResultFromFilterArray($filter_array, $isEmptyFilter); $result['id'] = $crtFilter->getAttribute('id'); if (($result['id'] == 0) && $isFullEmptyFilter) @@ -396,4 +396,4 @@ return false; } } -?> \ No newline at end of file +?> diff --git a/php/classes/IntervalCacheObject.php b/php/classes/IntervalCacheObject.php index 56b7804..c565e3a 100644 --- a/php/classes/IntervalCacheObject.php +++ b/php/classes/IntervalCacheObject.php @@ -8,7 +8,7 @@ class IntervalCacheObject protected $isNew = false; protected $isModified = false; - function __construct($id, $index) { + function __construct($id, $index = -1) { $this->id = $id; $this->index = $index; } @@ -111,4 +111,4 @@ class IntervalCacheObject echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".$this->start.", stop = ".$this->stop.", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL; } } -?> \ No newline at end of file +?> diff --git a/php/classes/RequestMgr.php b/php/classes/RequestMgr.php index 497be37..69ea67b 100644 --- a/php/classes/RequestMgr.php +++ b/php/classes/RequestMgr.php @@ -249,7 +249,7 @@ class RequestMgr extends AmdaObjectMgr if ($param->template_args->url_XYZ) $params[] = $param->template_args->url_XYZ; } } - if (count($params) > 0) + if (!empty($params)) { $argsTab['param'] = array_unique($params); $argsTab['startTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->startDate; diff --git a/php/classes/TimeTableMgr.php b/php/classes/TimeTableMgr.php index bda0db2..8c88ffd 100644 --- a/php/classes/TimeTableMgr.php +++ b/php/classes/TimeTableMgr.php @@ -22,7 +22,7 @@ function timeFormat($myString) class TimeTableMgr extends AmdaObjectMgr { - function __construct($user, $sharedObject = FALSE) + function __construct($user = NULL, $sharedObject = FALSE) { parent::__construct('Tt.xml'); $this->contentRootId = 'timeTable-treeRootNode'; diff --git a/php/classes/UserMgr.php b/php/classes/UserMgr.php index deb70f5..0979b38 100644 --- a/php/classes/UserMgr.php +++ b/php/classes/UserMgr.php @@ -28,7 +28,7 @@ class UserMgr public $isNewInfo = false; public $isSpecialInfo = null; - function __construct($username,$password,$sessionID) + function __construct($username = NULL, $password = NULL, $sessionID = NULL) { // if magic quotes is on, stripslashes if(get_magic_quotes_gpc()) @@ -165,10 +165,10 @@ class UserMgr } public function setSpecialSettings() - { + { $userSettings = new DomDocument("1.0"); - if (!$userSettings->load(specialSettingsXml)) { + if (!file_exists(specialSettingsXml) || !$userSettings->load(specialSettingsXml)) { define("DISK_QUOTA", DISK_QUOTA_standard); return; } @@ -293,6 +293,8 @@ class UserMgr { $remoteBases = new DomDocument("1.0"); $availableMis = $this->userMissions['external']; + if (!isset($availableMis)) + $availableMis = array(); unlink(USERWSDIR.'RemoteParams.xml'); if (file_exists(USERWSDIR.'RemoteParams.xml')) { @@ -381,7 +383,7 @@ unlink(USERWSDIR.'RemoteParams.xml'); if (!file_exists(RemoteData.$baseId.'/base.xml')) continue; // can't read base.xml ; skip this data base - if (!$baseXml->load(RemoteData.$baseId.'/base.xml')) continue; + if (!@$baseXml->load(RemoteData.$baseId.'/base.xml')) continue; // Some small & well known data centers are included by default: // Each VI structure and VI (dataset) description at DD Server for them should exist @@ -646,7 +648,8 @@ unlink(USERWSDIR.'RemoteParams.xml'); public function dirSize($dir) { $handle = opendir($dir); - + + $mas = 0; while ($file = readdir($handle)) { if ($file != '..' && $file != '.' && !is_dir($dir.'/'.$file)) diff --git a/php/classes/VOTableMgr.php b/php/classes/VOTableMgr.php index 958f85b..a4a9758 100644 --- a/php/classes/VOTableMgr.php +++ b/php/classes/VOTableMgr.php @@ -42,11 +42,21 @@ class VOTableMgr { 'ignore_errors' => true ) ); + + // BRE - Add proxy host if exists + if (defined('HTTP_PROXY_HOST')) { + $options['http']['proxy'] = 'tcp://'.HTTP_PROXY_HOST; + $options['http']['request_fulluri'] = TRUE; + if (defined('HTTP_PROXY_USER')) { + $options['http']['header'] = "Proxy-Authorization: Basic ".base64_encode(HTTP_PROXY_USER); + } + } + $context = stream_context_create($options); libxml_set_streams_context($context); $this->xml = new DomDocument(); - if (!$this->xml->load($fileName)) { + if (!@$this->xml->load($fileName)) { $this->votable_error = 'Can not load xml file.'; return false; } diff --git a/php/router.php b/php/router.php index 24ac4e2..ca2b1ed 100644 --- a/php/router.php +++ b/php/router.php @@ -76,7 +76,7 @@ * Main */ - define('log',fopen('log','w')); +// define('log',fopen('log','w')); $isForm = false; $isUpload = false; @@ -135,5 +135,5 @@ echo json_encode($response); } - fclose(log); +// fclose(log); ?> -- libgit2 0.21.2