OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
navigation.php
Go to the documentation of this file.
1 <?php
5 class Navigation extends oxAdminView
6 {
7 
13  protected $_sAllowedHost = "http://admin.oxid-esales.com";
14 
21  public function render()
22  {
24  $myUtilsServer = oxRegistry::get("oxUtilsServer");
25 
26  $sItem = oxRegistry::getConfig()->getRequestParameter("item");
27  $sItem = $sItem ? basename($sItem) : false;
28  if (!$sItem) {
29  $sItem = "nav_frame.tpl";
30  $aFavorites = oxRegistry::getConfig()->getRequestParameter("favorites");
31  if (is_array($aFavorites)) {
32  $myUtilsServer->setOxCookie('oxidadminfavorites', implode('|', $aFavorites));
33  }
34  } else {
35  $oNavTree = $this->getNavigation();
36 
37  // set menu structure
38  $this->_aViewData["menustructure"] = $oNavTree->getDomXml()->documentElement->childNodes;
39 
40  // version patch strin
41  $sVersion = str_replace(array("EE.", "PE."), "", $this->_sShopVersion);
42  $this->_aViewData["sVersion"] = trim($sVersion);
43 
44  //checking requirements if this is not nav frame reload
45  if (!oxRegistry::getConfig()->getRequestParameter("navReload")) {
46  // #661 execute stuff we run each time when we start admin once
47  if ('home.tpl' == $sItem) {
48  $this->_aViewData['aMessage'] = $this->_doStartUpChecks();
49  }
50  } else {
51  //removing reload param to force requirements checking next time
52  oxRegistry::getSession()->deleteVariable("navReload");
53  }
54 
55  // favorite navigation
56  $aFavorites = explode('|', $myUtilsServer->getOxCookie('oxidadminfavorites'));
57 
58  if (is_array($aFavorites) && count($aFavorites)) {
59  $this->_aViewData["menufavorites"] = $oNavTree->getListNodes($aFavorites);
60  $this->_aViewData["aFavorites"] = $aFavorites;
61  }
62 
63  // history navigation
64  $aHistory = explode('|', $myUtilsServer->getOxCookie('oxidadminhistory'));
65  if (is_array($aHistory) && count($aHistory)) {
66  $this->_aViewData["menuhistory"] = $oNavTree->getListNodes($aHistory);
67  }
68 
69  // open history node ?
70  $this->_aViewData["blOpenHistory"] = oxRegistry::getConfig()->getRequestParameter('openHistory');
71  }
72 
73  $sWhere = '';
74  $blisMallAdmin = oxRegistry::getSession()->getVariable('malladmin');
76  $oShoplist = oxNew('oxShopList');
77  if (!$blisMallAdmin) {
78  // we only allow to see our shop
79  $iShopId = oxRegistry::getSession()->getVariable("actshop");
81  $oShop = oxNew('oxShop');
82  $oShop->load($iShopId);
83  $oShoplist->add($oShop);
84  } else {
85  $oShoplist->getIdTitleList();
86  }
87 
88  $this->_aViewData['shoplist'] = $oShoplist;
89  return $sItem;
90  }
91 
95  public function chshp()
96  {
97  parent::chshp();
98 
99  // informing about basefrm parameters
100  $this->_aViewData['loadbasefrm'] = true;
101  $sListView = oxRegistry::getConfig()->getRequestParameter('listview');
102  $sEditView = oxRegistry::getConfig()->getRequestParameter('editview');
103  $iActEdit = oxRegistry::getConfig()->getRequestParameter('actedit');
104 
105 
106  $this->_aViewData['listview'] = $sListView;
107  $this->_aViewData['editview'] = $sEditView;
108  $this->_aViewData['actedit'] = $iActEdit;
109  }
110 
114  public function logout()
115  {
116  $mySession = $this->getSession();
117  $myConfig = $this->getConfig();
118 
119  $oUser = oxNew("oxuser");
120  $oUser->logout();
121 
122  // kill session
123  $mySession->destroy();
124 
125  // @deprecated since v5.3.0 (2016-05-24); Implement your own session handler with a module.
126  // delete also, this is usually not needed but for security reasons we execute still
127  if ($myConfig->getConfigParam('blAdodbSessionHandler')) {
128  $oDb = oxDb::getDb();
129  $oDb->execute("delete from oxsessions where SessionID = " . $oDb->quote($mySession->getId()));
130  }
131  // END deprecated
132 
133  //reseting content cache if needed
134  if ($myConfig->getConfigParam('blClearCacheOnLogout')) {
135  $this->resetContentCache(true);
136  }
137 
138  oxRegistry::getUtils()->redirect('index.php', true, 302);
139  }
140 
144  public function exturl()
145  {
146  $myUtils = oxRegistry::getUtils();
147  if ($sUrl = oxRegistry::getConfig()->getRequestParameter("url")) {
148 
149  // Limit external url's only allowed host
150  $myConfig = $this->getConfig();
151  if ($myConfig->getConfigParam('blLoadDynContents') && strpos($sUrl, $this->_sAllowedHost) === 0) {
152 
153  $sPath = $myConfig->getConfigParam('sCompileDir') . "/" . md5($sUrl) . '.html';
154  if ($myUtils->getRemoteCachePath($sUrl, $sPath)) {
155 
156  $oStr = getStr();
157  $sVersion = $myConfig->getVersion();
158  $sEdition = $myConfig->getFullEdition();
159  $sCurYear = date("Y");
160 
161  // Get ceontent
162  $sOutput = file_get_contents($sPath);
163 
164  // Fix base path
165  $sOutput = $oStr->preg_replace("/<\/head>/i", "<base href=\"" . dirname($sUrl) . '/' . "\"></head>\n <!-- OXID eShop {$sEdition}, Version {$sVersion}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->", $sOutput);
166 
167  // Fix self url's
168  $myUtils->showMessageAndExit($oStr->preg_replace("/href=\"#\"/i", 'href="javascript::void();"', $sOutput));
169  }
170  } else {
171  // Caching not allowed, redirecting
172  $myUtils->redirect($sUrl, true, 302);
173  }
174  }
175 
176  $myUtils->showMessageAndExit("");
177  }
178 
185  protected function _doStartUpChecks()
186  { // #661
187  $aMessage = array();
188 
189  // check if system reguirements are ok
190  $oSysReq = new oxSysRequirements();
191  if (!$oSysReq->getSysReqStatus()) {
192  $aMessage['warning'] = oxRegistry::getLang()->translateString('NAVIGATION_SYSREQ_MESSAGE');
193  $aMessage['warning'] .= '<a href="?cl=sysreq&amp;stoken=' . $this->getSession()->getSessionChallengeToken() . '" target="basefrm">';
194  $aMessage['warning'] .= oxRegistry::getLang()->translateString('NAVIGATION_SYSREQ_MESSAGE2') . '</a>';
195  }
196 
197  // version check
198  if ($this->getConfig()->getConfigParam('blCheckForUpdates')) {
199  if ($sVersionNotice = $this->_checkVersion()) {
200  $aMessage['message'] .= $sVersionNotice;
201  }
202  }
203 
204 
205  // check if setup dir is deleted
206  if (file_exists($this->getConfig()->getConfigParam('sShopDir') . '/setup/index.php')) {
207  $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('SETUP_DIRNOTDELETED_WARNING');
208  }
209 
210  // check if updateApp dir is deleted or empty
211  $sUpdateDir = $this->getConfig()->getConfigParam('sShopDir') . '/updateApp/';
212  if (file_exists($sUpdateDir) && !(count(glob("$sUpdateDir/*")) === 0)) {
213  $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('UPDATEAPP_DIRNOTDELETED_WARNING');
214  }
215 
216  // check if config file is writable
217  $sConfPath = $this->getConfig()->getConfigParam('sShopDir') . "/config.inc.php";
218  if (!is_readable($sConfPath) || is_writable($sConfPath)) {
219  $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('SETUP_CONFIGPERMISSIONS_WARNING');
220  }
221 
222  return $aMessage;
223  }
224 
230  protected function _checkVersion()
231  {
232  $sVersion = 'CE';
233 
234  $sQuery = 'http://admin.oxid-esales.com/' . $sVersion . '/onlinecheck.php?getlatestversion';
235  if ($sVersion = oxRegistry::get("oxUtilsFile")->readRemoteFileAsString($sQuery)) {
236  // current version is older ..
237  if (version_compare($this->getConfig()->getVersion(), $sVersion) == '-1') {
238  return sprintf(oxRegistry::getLang()->translateString('NAVIGATION_NEWVERSIONAVAILABLE'), $sVersion);
239  }
240  }
241  }
242 }