OXID eShop CE  4.9.10
 All Classes Files Functions Variables Pages
diagnostics_main.php
Go to the documentation of this file.
1 <?php
2 
8 {
9 
15  protected $_blError = false;
16 
22  protected $_sErrorMessage = null;
23 
29  protected $_oDiagnostics = null;
30 
36  protected $_oRenderer = null;
37 
43  protected $_oOutput = null;
44 
50  protected $_sShopDir = '';
51 
57  protected function _hasError()
58  {
59  return $this->_blError;
60  }
61 
67  protected function _getErrorMessage()
68  {
69  return $this->_sErrorMessage;
70  }
71 
72 
77  public function __construct()
78  {
80 
81  $this->_sShopDir = $this->getConfig()->getConfigParam('sShopDir');
82  $this->_oOutput = oxNew("oxDiagnosticsOutput");
83  $this->_oRenderer = oxNew("oxSmartyRenderer");
84  }
85 
91  public function render()
92  {
94 
95  if ($this->_hasError()) {
96  $this->_aViewData['sErrorMessage'] = $this->_getErrorMessage();
97  }
98 
99  return "diagnostics_form.tpl";
100  }
101 
107  protected function _getFilesToCheck()
108  {
109  $oDiagnostics = oxNew('oxDiagnostics');
110  $aFilePathList = $oDiagnostics->getFileCheckerPathList();
111  $aFileExtensionList = $oDiagnostics->getFileCheckerExtensionList();
112 
113  $oFileCollector = oxNew("oxFileCollector");
114  $oFileCollector->setBaseDirectory($this->_sShopDir);
115 
116  foreach ($aFilePathList as $sPath) {
117  if (is_file($this->_sShopDir . $sPath)) {
118  $oFileCollector->addFile($sPath);
119  } elseif (is_dir($this->_sShopDir . $sPath)) {
120  $oFileCollector->addDirectoryFiles($sPath, $aFileExtensionList, true);
121  }
122  }
123 
124  return $oFileCollector->getFiles();
125  }
126 
134  protected function _checkOxidFiles($aFileList)
135  {
136  $oFileChecker = oxNew("oxFileChecker");
137  $oFileChecker->setBaseDirectory($this->_sShopDir);
138  $oFileChecker->setVersion($this->getConfig()->getVersion());
139  $oFileChecker->setEdition($this->getConfig()->getEdition());
140  $oFileChecker->setRevision($this->getConfig()->getRevision());
141 
142  if (!$oFileChecker->init()) {
143  $this->_blError = true;
144  $this->_sErrorMessage = $oFileChecker->getErrorMessage();
145 
146  return null;
147  }
148 
149  $oFileCheckerResult = oxNew("oxFileCheckerResult");
150 
151  $blListAllFiles = ($this->getParam('listAllFiles') == 'listAllFiles');
152  $oFileCheckerResult->setListAllFiles($blListAllFiles);
153 
154  foreach ($aFileList as $sFile) {
155  $aCheckResult = $oFileChecker->checkFile($sFile);
156  $oFileCheckerResult->addResult($aCheckResult);
157  }
158 
159  return $oFileCheckerResult;
160  }
161 
169  protected function _getFileCheckReport($oFileCheckerResult)
170  {
171  $aViewData = array(
172  "sVersion" => $this->getConfig()->getVersion(),
173  "sEdition" => $this->getConfig()->getEdition(),
174  "sRevision" => $this->getConfig()->getRevision(),
175  "aResultSummary" => $oFileCheckerResult->getResultSummary(),
176  "aResultOutput" => $oFileCheckerResult->getResult(),
177  );
178 
179  return $this->_oRenderer->renderTemplate("version_checker_result.tpl", $aViewData);
180  }
181 
187  public function startDiagnostics()
188  {
189  $sReport = "";
190 
191  $aDiagnosticsResult = $this->_runBasicDiagnostics();
192  $sReport .= $this->_oRenderer->renderTemplate("diagnostics_main.tpl", $aDiagnosticsResult);
193 
194  if ($this->getParam('oxdiag_frm_chkvers')) {
195  $aFileList = $this->_getFilesToCheck();
196  $oFileCheckerResult = $this->_checkOxidFiles($aFileList);
197 
198  if ($this->_hasError()) {
199  return;
200  }
201 
202  $sReport .= $this->_getFileCheckReport($oFileCheckerResult);
203  }
204 
205  $this->_oOutput->storeResult($sReport);
206 
207  $sResult = $this->_oOutput->readResultFile();
208  $this->_aViewData['sResult'] = $sResult;
209  }
210 
217  protected function _runBasicDiagnostics()
218  {
219  $aViewData = array();
220  $oDiagnostics = oxNew('oxDiagnostics');
221 
222  $oDiagnostics->setShopLink(oxRegistry::getConfig()->getConfigParam('sShopURL'));
223  $oDiagnostics->setEdition(oxRegistry::getConfig()->getFullEdition());
224  $oDiagnostics->setVersion(oxRegistry::getConfig()->getVersion());
225  $oDiagnostics->setRevision(oxRegistry::getConfig()->getRevision());
226 
230  if ($this->getParam('runAnalysis')) {
231  $aViewData['runAnalysis'] = true;
232  $aViewData['aShopDetails'] = $oDiagnostics->getShopDetails();
233  }
234 
238  if ($this->getParam('oxdiag_frm_modules')) {
239 
240  $sModulesDir = $this->getConfig()->getModulesDir();
241  $oModuleList = oxNew('oxModuleList');
242  $aModules = $oModuleList->getModulesFromDir($sModulesDir);
243 
244  $aViewData['oxdiag_frm_modules'] = true;
245  $aViewData['mylist'] = $aModules;
246  }
247 
251  if ($this->getParam('oxdiag_frm_health')) {
252 
253  $oSysReq = new oxSysRequirements();
254  $aViewData['oxdiag_frm_health'] = true;
255  $aViewData['aInfo'] = $oSysReq->getSystemInfo();
256  $aViewData['aCollations'] = $oSysReq->checkCollation();
257  }
258 
263  if ($this->getParam('oxdiag_frm_php')) {
264  $aViewData['oxdiag_frm_php'] = true;
265  $aViewData['aPhpConfigparams'] = $oDiagnostics->getPhpSelection();
266  $aViewData['sPhpDecoder'] = $oDiagnostics->getPhpDecoder();
267  }
268 
272  if ($this->getParam('oxdiag_frm_server')) {
273  $aViewData['isExecAllowed'] = $oDiagnostics->isExecAllowed();
274  $aViewData['oxdiag_frm_server'] = true;
275  $aViewData['aServerInfo'] = $oDiagnostics->getServerInfo();
276  }
277 
278  if ($this->getParam('oxdiag_frm_chkvers')) {
279  $aViewData['oxdiag_frm_chkvers'] = true;
280  }
281 
282  return $aViewData;
283  }
284 
288  public function downloadResultFile()
289  {
290  $this->_oOutput->downloadResultFile();
291  exit();
292  }
293 
299  public function getSupportContactForm()
300  {
301  $aLinks = array(
302  "de" => "http://www.oxid-esales.com/de/support-services/supportanfrage.html",
303  "en" => "http://www.oxid-esales.com/en/support-services/support-request.html"
304  );
305 
306  $oLang = oxRegistry::getLang();
307  $aLanguages = $oLang->getLanguageArray();
308  $iLangId = $oLang->getTplLanguage();
309  $sLangCode = $aLanguages[$iLangId]->abbr;
310 
311  if (!array_key_exists($sLangCode, $aLinks)) {
312  $sLangCode = "de";
313  }
314 
315  return $aLinks[$sLangCode];
316  }
317 
325  public function getParam($sParam)
326  {
327  return $this->getConfig()->getRequestParameter($sParam);
328  }
329 }