OXID eShop CE  4.8.12
 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 
73 
78  public function __construct()
79  {
81 
82  $this->_sShopDir = $this->getConfig()->getConfigParam( 'sShopDir' );
83  $this->_oOutput = oxNew ( "oxDiagnosticsOutput" );
84  $this->_oRenderer = oxNew ( "oxSmartyRenderer" );
85  }
86 
92  public function render()
93  {
95 
96  if ( $this->_hasError() ) {
97  $this->_aViewData['sErrorMessage'] = $this->_getErrorMessage();
98  }
99 
100  return "diagnostics_form.tpl";
101  }
102 
108  protected function _getFilesToCheck()
109  {
110  $oDiagnostics = oxNew( 'oxDiagnostics' );
111  $aFilePathList = $oDiagnostics->getFileCheckerPathList();
112  $aFileExtensionList = $oDiagnostics->getFileCheckerExtensionList();
113 
114  $oFileCollector = oxNew ( "oxFileCollector" );
115  $oFileCollector->setBaseDirectory( $this->_sShopDir );
116 
117  foreach ( $aFilePathList as $sPath ) {
118  if ( is_file( $this->_sShopDir . $sPath ) ) {
119  $oFileCollector->addFile( $sPath );
120  }
121  elseif ( is_dir( $this->_sShopDir . $sPath ) ) {
122  $oFileCollector->addDirectoryFiles( $sPath, $aFileExtensionList, true );
123  }
124  }
125 
126  return $oFileCollector->getFiles();
127  }
128 
135  protected function _checkOxidFiles( $aFileList )
136  {
137  $oFileChecker = oxNew ( "oxFileChecker" );
138  $oFileChecker->setBaseDirectory( $this->_sShopDir );
139  $oFileChecker->setVersion( $this->getConfig()->getVersion() );
140  $oFileChecker->setEdition( $this->getConfig()->getEdition() );
141  $oFileChecker->setRevision( $this->getConfig()->getRevision() );
142 
143  if ( !$oFileChecker->init() ) {
144  $this->_blError = true;
145  $this->_sErrorMessage = $oFileChecker->getErrorMessage();
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 
168  protected function _getFileCheckReport( $oFileCheckerResult )
169  {
170  $aViewData = array(
171  "sVersion" => $this->getConfig()->getVersion(),
172  "sEdition" => $this->getConfig()->getEdition(),
173  "sRevision" => $this->getConfig()->getRevision(),
174  "aResultSummary" => $oFileCheckerResult->getResultSummary(),
175  "aResultOutput" => $oFileCheckerResult->getResult(),
176  );
177 
178  return $this->_oRenderer->renderTemplate( "version_checker_result.tpl", $aViewData );
179  }
180 
186  public function startDiagnostics()
187  {
188  $sReport = "";
189 
190  $aDiagnosticsResult = $this->_runBasicDiagnostics();
191  $sReport .= $this->_oRenderer->renderTemplate( "diagnostics_main.tpl", $aDiagnosticsResult );
192 
193  if ( $this->getParam('oxdiag_frm_chkvers' ) )
194  {
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 
211 
212  protected function _runBasicDiagnostics()
213  {
214  $aViewData = array();
215  $oDiagnostics = oxNew( 'oxDiagnostics' );
216 
217  $oDiagnostics->setShopLink( oxRegistry::getConfig()->getConfigParam( 'sShopURL' ) );
218  $oDiagnostics->setEdition( oxRegistry::getConfig()->getFullEdition() );
219  $oDiagnostics->setVersion( oxRegistry::getConfig()->getVersion() );
220  $oDiagnostics->setRevision( oxRegistry::getConfig()->getRevision() );
221 
225  if ( $this->getParam( 'runAnalysis' ) ) {
226  $aViewData['runAnalysis'] = true;
227  $aViewData['aShopDetails'] = $oDiagnostics->getShopDetails();
228  }
229 
233  if ( $this->getParam('oxdiag_frm_modules' ) ) {
234 
235  $sModulesDir = $this->getConfig()->getModulesDir();
236  $oModuleList = oxNew('oxModuleList');
237  $aModules = $oModuleList->getModulesFromDir( $sModulesDir);
238 
239  $aViewData['oxdiag_frm_modules'] = true;
240  $aViewData['mylist'] = $aModules;
241  }
242 
246  if ( $this->getParam('oxdiag_frm_health' ) ) {
247 
248  $oSysReq = new oxSysRequirements();
249  $aViewData['oxdiag_frm_health'] = true;
250  $aViewData['aInfo'] = $oSysReq->getSystemInfo();
251  $aViewData['aCollations'] = $oSysReq->checkCollation();
252  }
253 
258  if ( $this->getParam('oxdiag_frm_php' ) ) {
259  $aViewData['oxdiag_frm_php'] = true;
260  $aViewData['aPhpConfigparams'] = $oDiagnostics->getPhpSelection();
261  $aViewData['sPhpDecoder'] = $oDiagnostics->getPhpDecoder();
262  }
263 
267  if ( $this->getParam('oxdiag_frm_server' ) ) {
268  $aViewData['isExecAllowed'] = $oDiagnostics->isExecAllowed();
269  $aViewData['oxdiag_frm_server'] = true;
270  $aViewData['aServerInfo'] = $oDiagnostics->getServerInfo();
271  }
272 
273  if ( $this->getParam('oxdiag_frm_chkvers' ) ) {
274  $aViewData['oxdiag_frm_chkvers'] = true;
275  }
276 
277  return $aViewData;
278  }
279 
285  public function downloadResultFile()
286  {
287  $this->_oOutput->downloadResultFile();
288  exit();
289  }
290 
296  public function getSupportContactForm()
297  {
298  $aLinks = array(
299  "de" => "http://www.oxid-esales.com/de/support-services/supportanfrage.html",
300  "en" => "http://www.oxid-esales.com/en/support-services/support-request.html"
301  );
302 
303  $oLang = oxRegistry::getLang();
304  $aLanguages = $oLang->getLanguageArray();
305  $iLangId = $oLang->getTplLanguage();
306  $sLangCode = $aLanguages[$iLangId]->abbr;
307 
308  if (!array_key_exists( $sLangCode, $aLinks))
309  $sLangCode = "de";
310 
311  return $aLinks[$sLangCode];
312  }
313 
320  public function getParam( $sParam )
321  {
322  return $this->getConfig()->getRequestParameter( $sParam );
323  }
324 
325 }