OXID eShop CE  4.9.6
 All Classes 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  // delete also, this is usually not needed but for security reasons we execute still
126  if ($myConfig->getConfigParam('blAdodbSessionHandler')) {
127  $oDb = oxDb::getDb();
128  $oDb->execute("delete from oxsessions where SessionID = " . $oDb->quote($mySession->getId()));
129  }
130 
131  //reseting content cache if needed
132  if ($myConfig->getConfigParam('blClearCacheOnLogout')) {
133  $this->resetContentCache(true);
134  }
135 
136  oxRegistry::getUtils()->redirect('index.php', true, 302);
137  }
138 
142  public function exturl()
143  {
144  $myUtils = oxRegistry::getUtils();
145  if ($sUrl = oxRegistry::getConfig()->getRequestParameter("url")) {
146 
147  // Limit external url's only allowed host
148  $myConfig = $this->getConfig();
149  if ($myConfig->getConfigParam('blLoadDynContents') && strpos($sUrl, $this->_sAllowedHost) === 0) {
150 
151  $sPath = $myConfig->getConfigParam('sCompileDir') . "/" . md5($sUrl) . '.html';
152  if ($myUtils->getRemoteCachePath($sUrl, $sPath)) {
153 
154  $oStr = getStr();
155  $sVersion = $myConfig->getVersion();
156  $sEdition = $myConfig->getFullEdition();
157  $sCurYear = date("Y");
158 
159  // Get ceontent
160  $sOutput = file_get_contents($sPath);
161 
162  // Fix base path
163  $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);
164 
165  // Fix self url's
166  $myUtils->showMessageAndExit($oStr->preg_replace("/href=\"#\"/i", 'href="javascript::void();"', $sOutput));
167  }
168  } else {
169  // Caching not allowed, redirecting
170  $myUtils->redirect($sUrl, true, 302);
171  }
172  }
173 
174  $myUtils->showMessageAndExit("");
175  }
176 
183  protected function _doStartUpChecks()
184  { // #661
185  $aMessage = array();
186 
187  // check if system reguirements are ok
188  $oSysReq = new oxSysRequirements();
189  if (!$oSysReq->getSysReqStatus()) {
190  $aMessage['warning'] = oxRegistry::getLang()->translateString('NAVIGATION_SYSREQ_MESSAGE');
191  $aMessage['warning'] .= '<a href="?cl=sysreq&amp;stoken=' . $this->getSession()->getSessionChallengeToken() . '" target="basefrm">';
192  $aMessage['warning'] .= oxRegistry::getLang()->translateString('NAVIGATION_SYSREQ_MESSAGE2') . '</a>';
193  }
194 
195  // version check
196  if ($this->getConfig()->getConfigParam('blCheckForUpdates')) {
197  if ($sVersionNotice = $this->_checkVersion()) {
198  $aMessage['message'] .= $sVersionNotice;
199  }
200  }
201 
202 
203  // check if setup dir is deleted
204  if (file_exists($this->getConfig()->getConfigParam('sShopDir') . '/setup/index.php')) {
205  $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('SETUP_DIRNOTDELETED_WARNING');
206  }
207 
208  // check if updateApp dir is deleted or empty
209  $sUpdateDir = $this->getConfig()->getConfigParam('sShopDir') . '/updateApp/';
210  if (file_exists($sUpdateDir) && !(count(glob("$sUpdateDir/*")) === 0)) {
211  $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('UPDATEAPP_DIRNOTDELETED_WARNING');
212  }
213 
214  // check if config file is writable
215  $sConfPath = $this->getConfig()->getConfigParam('sShopDir') . "/config.inc.php";
216  if (!is_readable($sConfPath) || is_writable($sConfPath)) {
217  $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('SETUP_CONFIGPERMISSIONS_WARNING');
218  }
219 
220  return $aMessage;
221  }
222 
228  protected function _checkVersion()
229  {
230  $sVersion = 'CE';
231 
232  $sQuery = 'http://admin.oxid-esales.com/' . $sVersion . '/onlinecheck.php?getlatestversion';
233  if ($sVersion = oxRegistry::get("oxUtilsFile")->readRemoteFileAsString($sQuery)) {
234  // current version is older ..
235  if (version_compare($this->getConfig()->getVersion(), $sVersion) == '-1') {
236  return sprintf(oxRegistry::getLang()->translateString('NAVIGATION_NEWVERSIONAVAILABLE'), $sVersion);
237  }
238  }
239  }
240 }