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