Go to the documentation of this file.00001 <?php
00002
00007 class Diagnostics_Main extends oxAdminDetails
00008 {
00009
00015 protected $_blError = false;
00016
00022 protected $_sErrorMessage = null;
00023
00029 protected $_oDiagnostics = null;
00030
00036 protected $_oRenderer = null;
00037
00043 protected $_oOutput = null;
00044
00050 protected $_sShopDir = '';
00051
00057 protected function _hasError()
00058 {
00059 return $this->_blError;
00060 }
00061
00067 protected function _getErrorMessage()
00068 {
00069 return $this->_sErrorMessage;
00070 }
00071
00072
00077 public function __construct()
00078 {
00079 parent::__construct();
00080
00081 $this->_sShopDir = $this->getConfig()->getConfigParam('sShopDir');
00082 $this->_oOutput = oxNew("oxDiagnosticsOutput");
00083 $this->_oRenderer = oxNew("oxSmartyRenderer");
00084 }
00085
00091 public function render()
00092 {
00093 parent::render();
00094
00095 if ($this->_hasError()) {
00096 $this->_aViewData['sErrorMessage'] = $this->_getErrorMessage();
00097 }
00098
00099 return "diagnostics_form.tpl";
00100 }
00101
00107 protected function _getFilesToCheck()
00108 {
00109 $oDiagnostics = oxNew('oxDiagnostics');
00110 $aFilePathList = $oDiagnostics->getFileCheckerPathList();
00111 $aFileExtensionList = $oDiagnostics->getFileCheckerExtensionList();
00112
00113 $oFileCollector = oxNew("oxFileCollector");
00114 $oFileCollector->setBaseDirectory($this->_sShopDir);
00115
00116 foreach ($aFilePathList as $sPath) {
00117 if (is_file($this->_sShopDir . $sPath)) {
00118 $oFileCollector->addFile($sPath);
00119 } elseif (is_dir($this->_sShopDir . $sPath)) {
00120 $oFileCollector->addDirectoryFiles($sPath, $aFileExtensionList, true);
00121 }
00122 }
00123
00124 return $oFileCollector->getFiles();
00125 }
00126
00134 protected function _checkOxidFiles($aFileList)
00135 {
00136 $oFileChecker = oxNew("oxFileChecker");
00137 $oFileChecker->setBaseDirectory($this->_sShopDir);
00138 $oFileChecker->setVersion($this->getConfig()->getVersion());
00139 $oFileChecker->setEdition($this->getConfig()->getEdition());
00140 $oFileChecker->setRevision($this->getConfig()->getRevision());
00141
00142 if (!$oFileChecker->init()) {
00143 $this->_blError = true;
00144 $this->_sErrorMessage = $oFileChecker->getErrorMessage();
00145
00146 return null;
00147 }
00148
00149 $oFileCheckerResult = oxNew("oxFileCheckerResult");
00150
00151 $blListAllFiles = ($this->getParam('listAllFiles') == 'listAllFiles');
00152 $oFileCheckerResult->setListAllFiles($blListAllFiles);
00153
00154 foreach ($aFileList as $sFile) {
00155 $aCheckResult = $oFileChecker->checkFile($sFile);
00156 $oFileCheckerResult->addResult($aCheckResult);
00157 }
00158
00159 return $oFileCheckerResult;
00160 }
00161
00169 protected function _getFileCheckReport($oFileCheckerResult)
00170 {
00171 $aViewData = array(
00172 "sVersion" => $this->getConfig()->getVersion(),
00173 "sEdition" => $this->getConfig()->getEdition(),
00174 "sRevision" => $this->getConfig()->getRevision(),
00175 "aResultSummary" => $oFileCheckerResult->getResultSummary(),
00176 "aResultOutput" => $oFileCheckerResult->getResult(),
00177 );
00178
00179 return $this->_oRenderer->renderTemplate("version_checker_result.tpl", $aViewData);
00180 }
00181
00187 public function startDiagnostics()
00188 {
00189 $sReport = "";
00190
00191 $aDiagnosticsResult = $this->_runBasicDiagnostics();
00192 $sReport .= $this->_oRenderer->renderTemplate("diagnostics_main.tpl", $aDiagnosticsResult);
00193
00194 if ($this->getParam('oxdiag_frm_chkvers')) {
00195 $aFileList = $this->_getFilesToCheck();
00196 $oFileCheckerResult = $this->_checkOxidFiles($aFileList);
00197
00198 if ($this->_hasError()) {
00199 return;
00200 }
00201
00202 $sReport .= $this->_getFileCheckReport($oFileCheckerResult);
00203 }
00204
00205 $this->_oOutput->storeResult($sReport);
00206
00207 $sResult = $this->_oOutput->readResultFile();
00208 $this->_aViewData['sResult'] = $sResult;
00209 }
00210
00217 protected function _runBasicDiagnostics()
00218 {
00219 $aViewData = array();
00220 $oDiagnostics = oxNew('oxDiagnostics');
00221
00222 $oDiagnostics->setShopLink(oxRegistry::getConfig()->getConfigParam('sShopURL'));
00223 $oDiagnostics->setEdition(oxRegistry::getConfig()->getFullEdition());
00224 $oDiagnostics->setVersion(oxRegistry::getConfig()->getVersion());
00225 $oDiagnostics->setRevision(oxRegistry::getConfig()->getRevision());
00226
00230 if ($this->getParam('runAnalysis')) {
00231 $aViewData['runAnalysis'] = true;
00232 $aViewData['aShopDetails'] = $oDiagnostics->getShopDetails();
00233 }
00234
00238 if ($this->getParam('oxdiag_frm_modules')) {
00239
00240 $sModulesDir = $this->getConfig()->getModulesDir();
00241 $oModuleList = oxNew('oxModuleList');
00242 $aModules = $oModuleList->getModulesFromDir($sModulesDir);
00243
00244 $aViewData['oxdiag_frm_modules'] = true;
00245 $aViewData['mylist'] = $aModules;
00246 }
00247
00251 if ($this->getParam('oxdiag_frm_health')) {
00252
00253 $oSysReq = new oxSysRequirements();
00254 $aViewData['oxdiag_frm_health'] = true;
00255 $aViewData['aInfo'] = $oSysReq->getSystemInfo();
00256 $aViewData['aCollations'] = $oSysReq->checkCollation();
00257 }
00258
00263 if ($this->getParam('oxdiag_frm_php')) {
00264 $aViewData['oxdiag_frm_php'] = true;
00265 $aViewData['aPhpConfigparams'] = $oDiagnostics->getPhpSelection();
00266 $aViewData['sPhpDecoder'] = $oDiagnostics->getPhpDecoder();
00267 }
00268
00272 if ($this->getParam('oxdiag_frm_server')) {
00273 $aViewData['isExecAllowed'] = $oDiagnostics->isExecAllowed();
00274 $aViewData['oxdiag_frm_server'] = true;
00275 $aViewData['aServerInfo'] = $oDiagnostics->getServerInfo();
00276 }
00277
00278 if ($this->getParam('oxdiag_frm_chkvers')) {
00279 $aViewData['oxdiag_frm_chkvers'] = true;
00280 }
00281
00282 return $aViewData;
00283 }
00284
00288 public function downloadResultFile()
00289 {
00290 $this->_oOutput->downloadResultFile();
00291 exit();
00292 }
00293
00299 public function getSupportContactForm()
00300 {
00301 $aLinks = array(
00302 "de" => "http://www.oxid-esales.com/de/support-services/supportanfrage.html",
00303 "en" => "http://www.oxid-esales.com/en/support-services/support-request.html"
00304 );
00305
00306 $oLang = oxRegistry::getLang();
00307 $aLanguages = $oLang->getLanguageArray();
00308 $iLangId = $oLang->getTplLanguage();
00309 $sLangCode = $aLanguages[$iLangId]->abbr;
00310
00311 if (!array_key_exists($sLangCode, $aLinks)) {
00312 $sLangCode = "de";
00313 }
00314
00315 return $aLinks[$sLangCode];
00316 }
00317
00325 public function getParam($sParam)
00326 {
00327 return $this->getConfig()->getRequestParameter($sParam);
00328 }
00329 }