00001 <?php
00002
00006 require_once getShopBasePath()."core/smarty/Smarty.class.php";
00007
00012 class oxUtils extends oxSuperCfg
00013 {
00014
00020 private static $_instance = null;
00021
00027 protected $_iCurPrecision = null;
00028
00034 protected $_sEmailTpl = "^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~\177])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~\177]+\\.)+[a-zA-Z]{2,6}\$";
00035
00041 public static function getInstance()
00042 {
00043
00044 if ( defined( 'OXID_PHP_UNIT' ) ) {
00045 static $inst = array();
00046 self::$_instance = $inst[oxClassCacheKey()];
00047
00048 }
00049
00050 if ( !self::$_instance instanceof oxUtils ) {
00051
00052
00053 self::$_instance = oxNew( 'oxUtils' );
00054
00055 if ( defined( 'OXID_PHP_UNIT' ) ) {
00056 $inst[oxClassCacheKey()] = self::$_instance;
00057 }
00058 }
00059 return self::$_instance;
00060 }
00061
00067 protected $_aStaticCache;
00068
00074 protected $_blSeoIsActive = null;
00075
00081 public function stripGpcMagicQuotes()
00082 {
00083 if (!get_magic_quotes_gpc()) {
00084 return;
00085 }
00086 $_REQUEST = self::_stripQuotes($_REQUEST);
00087 $_POST = self::_stripQuotes($_POST);
00088 $_GET = self::_stripQuotes($_GET);
00089 $_COOKIE = self::_stripQuotes($_COOKIE);
00090 }
00091
00100 public function strMan( $sVal, $sKey = null )
00101 {
00102 $sKey = $sKey?$sKey:'oxid123456789';
00103 $sVal = "ox{$sVal}id";
00104
00105 $sKey = str_repeat( $sKey, strlen( $sVal ) / strlen( $sKey ) + 5 );
00106 $sVal = $this->strRot13( $sVal );
00107 $sVal = $sVal ^ $sKey;
00108 $sVal = base64_encode( $sVal );
00109 $sVal = str_replace( "=", "!", $sVal );
00110
00111 return "ox_$sVal";
00112 }
00113
00122 public function strRem( $sVal, $sKey = null )
00123 {
00124 $sKey = $sKey?$sKey:'oxid123456789';
00125 $sKey = str_repeat( $sKey, strlen( $sVal ) / strlen( $sKey ) + 5 );
00126
00127 $sVal = substr( $sVal, 3 );
00128 $sVal = str_replace( '!', '=', $sVal );
00129 $sVal = base64_decode( $sVal );
00130 $sVal = $sVal ^ $sKey;
00131 $sVal = $this->strRot13( $sVal );
00132
00133 return substr( $sVal, 2, -2 );
00134 }
00135
00143 public function getArrFldName( $sName)
00144 {
00145 return str_replace( ".", "__", $sName);
00146 }
00147
00156 public function assignValuesFromText( $sIn, $dVat = null)
00157 {
00158 $aRet = array();
00159 $aPieces = explode( '@@', $sIn );
00160 while ( list( $sKey, $sVal ) = each( $aPieces ) ) {
00161 if ( $sVal ) {
00162 $aName = explode( '__', $sVal );
00163 if ( isset( $aName[0] ) && isset( $aName[1] ) ) {
00164 $aRet[] = $this->_fillExplodeArray( $aName, $dVat );
00165 }
00166 }
00167 }
00168 return $aRet;
00169 }
00170
00178 public function assignValuesToText( $aIn)
00179 {
00180 $sRet = "";
00181 reset( $aIn );
00182 while (list($sKey, $sVal) = each($aIn)) {
00183 $sRet .= $sKey;
00184 $sRet .= "__";
00185 $sRet .= $sVal;
00186 $sRet .= "@@";
00187 }
00188 return $sRet;
00189 }
00190
00199 public function formatCurrency( $dValue, $oActCur = null )
00200 {
00201 if (!$oActCur) {
00202 $oActCur = $this->getConfig()->getActShopCurrencyObject();
00203 }
00204 $sFormated = number_format( $dValue, $oActCur->decimal, $oActCur->dec, $oActCur->thousand);
00205
00206 return $sFormated;
00207 }
00208
00216 public function currency2Float( $sValue)
00217 {
00218 $fRet = $sValue;
00219 $iPos = strrpos( $sValue, ".");
00220 if ($iPos && ((strlen($sValue)-1-$iPos) < 2+1)) {
00221
00222 $fRet = substr_replace( $fRet, ",", $iPos, 1);
00223 }
00224
00225 $fRet = str_replace( array(" ","."), "", $fRet);
00226
00227 $fRet = str_replace( ",", ".", $fRet);
00228 return (float) $fRet;
00229 }
00230
00238 public function isSearchEngine( $sClient = null )
00239 {
00240 $myConfig = $this->getConfig();
00241 $blIsSe = false;
00242
00243 if ( !( $myConfig->getConfigParam( 'iDebug' ) && $this->isAdmin() ) ) {
00244
00245
00246 $blIsSe = $myConfig->getGlobalParameter( 'blIsSearchEngine' );
00247 if ( !isset( $blIsSe ) ) {
00248
00249 $aRobots = $myConfig->getConfigParam( 'aRobots' );
00250 $aRobots = is_array( $aRobots )?$aRobots:array();
00251
00252 $aRobotsExcept = $myConfig->getConfigParam( 'aRobotsExcept' );
00253 $aRobotsExcept = is_array( $aRobotsExcept )?$aRobotsExcept:array();
00254
00255 $sClient = $sClient?$sClient:strtolower( getenv( 'HTTP_USER_AGENT' ) );
00256 $blIsSe = false;
00257 $aRobots = array_merge( $aRobots, $aRobotsExcept );
00258 foreach ( $aRobots as $sRobot ) {
00259 if ( strpos( $sClient, $sRobot ) !== false ) {
00260 $blIsSe = true;
00261 break;
00262 }
00263 }
00264 $myConfig->setGlobalParameter( 'blIsSearchEngine', $blIsSe );
00265 }
00266 }
00267
00268 return $blIsSe;
00269 }
00270
00279 public function isValidEmail( $sEmail )
00280 {
00281 $blValid = true;
00282 if ( $sEmail != 'admin' ) {
00283 $blValid = ( eregi( $this->_sEmailTpl, $sEmail ) != 0 );
00284 }
00285
00286 return $blValid;
00287 }
00288
00294 public function rebuildCache()
00295 {
00296
00297
00298
00299
00300
00301 if ( function_exists( "UserdefinedRebuildCache")) {
00302 UserdefinedRebuildCache();
00303 }
00304 }
00305
00313 public function loadAdminProfile($aInterfaceProfiles)
00314 {
00315
00316
00317 $aInterfaceProfiles = $aInterfaceProfiles;
00318 if ( is_array( $aInterfaceProfiles ) ) {
00319 $sPrevProfile = oxUtilsServer::getInstance()->getOxCookie('oxidadminprofile');
00320 if (isset($sPrevProfile)) {
00321 $aPrevProfile = @explode("@", trim($sPrevProfile));
00322 }
00323
00324
00325 $aProfiles = array();
00326 foreach ( $aInterfaceProfiles as $iPos => $sProfile) {
00327 $aProfileSettings = array($iPos, $sProfile);
00328 $aProfiles[] = $aProfileSettings;
00329 }
00330
00331 if (isset($aPrevProfile[0]) && isset($aProfiles[$aPrevProfile[0]])) {
00332 $aProfiles[$aPrevProfile[0]][2] = 1;
00333 }
00334
00335 oxSession::setVar("aAdminProfiles", $aProfiles);
00336 return $aProfiles;
00337 }
00338 return null;
00339 }
00340
00349 public function fRound($sVal, $oCur = null)
00350 {
00351 startProfile('fround');
00352
00353
00354 $iCurPrecision = null;
00355 if (! defined('OXID_PHP_UNIT')) {
00356 $iCurPrecision = $this->_iCurPrecision;
00357 }
00358
00359 if (is_null($iCurPrecision)) {
00360 if ( !$oCur ) {
00361 $oCur = $this->getConfig()->getActShopCurrencyObject();
00362 }
00363
00364 $iCurPrecision = $oCur->decimal;
00365 $this->_iCurPrecision = $iCurPrecision;
00366 }
00367
00368
00369 static $dprez = null;
00370 if (!$dprez) {
00371 $prez = @ini_get("precision");
00372 if (!$prez) {
00373 $prez = 9;
00374 }
00375 $dprez = pow(10, -$prez);
00376 }
00377
00378
00379 stopProfile('fround');
00380
00381 return round($sVal + $dprez, $iCurPrecision);
00382 }
00383
00393 public function toStaticCache( $sName, $sContent, $sKey = null )
00394 {
00395
00396 if ( $sKey ) {
00397 $this->_aStaticCache[$sName][$sKey] = $sContent;
00398 } else {
00399 $this->_aStaticCache[$sName] = $sContent;
00400 }
00401 }
00402
00410 public function fromStaticCache( $sName)
00411 {
00412 if ( isset( $this->_aStaticCache[$sName])) {
00413 return $this->_aStaticCache[$sName];
00414 }
00415 return null;
00416 }
00417
00425 public function cleanStaticCache($sCacheName = null)
00426 {
00427 if ($sCacheName) {
00428 unset($this->_aStaticCache[$sCacheName]);
00429 } else {
00430 $this->_aStaticCache = null;
00431 }
00432 }
00433
00443 protected function _oxFileCache( $blMode, $sName, $sInput = null )
00444 {
00445 $sFilePath = $this->_getCacheFilePath( $sName );
00446 $sRet = null;
00447 if ( $blMode) {
00448
00449
00450
00451
00452
00453 $hFile = fopen( $sFilePath, "w");
00454 if ( $hFile) {
00455 fwrite( $hFile, $sInput);
00456 fclose( $hFile);
00457 }
00458 } else {
00459 if ( file_exists( $sFilePath) && is_readable($sFilePath)) {
00460
00461 $sRet = file_get_contents( $sFilePath);
00462 }
00463 }
00464 return $sRet;
00465 }
00466
00475 public function toFileCache($sKey, $sContents)
00476 {
00477 $sStaticCacheKey = 'staticfilecache|' . $sKey;
00478 $this->toStaticCache($sStaticCacheKey, $sContents);
00479
00480 $sContents = serialize($sContents);
00481 return $this->_oxFileCache(true, $sKey, $sContents);
00482 }
00483
00491 public function fromFileCache( $sKey )
00492 {
00493 $sStaticCacheKey = "staticfilecache|$sKey";
00494
00495
00496 $sRes = $this->fromStaticCache( $sStaticCacheKey );
00497
00498 if ( is_null( $sRes ) ) {
00499 $sRes = $this->_oxFileCache( false, $sKey );
00500 if (!is_null($sRes)) {
00501 $sRes = unserialize( $sRes );
00502 $this->toStaticCache( $sStaticCacheKey, $sRes );
00503 }
00504 }
00505
00506 return $sRes;
00507 }
00508
00515 public function oxResetFileCache()
00516 {
00517 $aPathes = glob( $this->_getCacheFilePath( '*' ) );
00518 if ( is_array( $aPathes ) ) {
00519 foreach ( $aPathes as $sFilename ) {
00520
00521 @unlink( $sFilename );
00522 }
00523 }
00524 }
00525
00535 public function getRemoteCachePath($sRemote, $sLocal)
00536 {
00537 clearstatcache();
00538 if ( file_exists( $sLocal ) && filemtime( $sLocal ) && filemtime( $sLocal ) > time() - 86400 ) {
00539 return $sLocal;
00540 }
00541 $hRemote = @fopen( $sRemote, "rb");
00542 $blSuccess = false;
00543 if ( isset( $hRemote) && $hRemote ) {
00544 $hLocal = fopen( $sLocal, "wb");
00545 stream_copy_to_stream($hRemote, $hLocal);
00546 fclose($hRemote);
00547 fclose($hLocal);
00548 $blSuccess = true;
00549 } else {
00550
00551 $aUrl = @parse_url( $sRemote);
00552 if ( !empty( $aUrl["host"])) {
00553 $sPath = $aUrl["path"];
00554 if ( empty( $sPath ) ) {
00555 $sPath = "/";
00556 }
00557 $sHost = $aUrl["host"];
00558
00559 $hSocket = @fsockopen( $sHost, 80, $iErrorNumber, $iErrStr, 5);
00560 if ( $hSocket) {
00561 fputs( $hSocket, "GET ".$sPath." HTTP/1.0\r\nHost: $sHost\r\n\r\n");
00562 $headers = stream_get_line($hSocket, 4096, "\r\n\r\n");
00563 $hLocal = @fopen( $sLocal, "wb");
00564 stream_copy_to_stream($hSocket, $hLocal);
00565 fclose( $hSocket);
00566 fclose($hLocal);
00567 $blSuccess = true;
00568 }
00569 }
00570 }
00571 if ( $blSuccess || file_exists( $sLocal ) ) {
00572 return $sLocal;
00573 } else {
00574 return false;
00575 }
00576 }
00577
00583 public function checkAccessRights()
00584 {
00585 $myConfig = $this->getConfig();
00586
00587 $blIsAuth = false;
00588
00589 $sUserID = oxSession::getVar( "auth");
00590
00591
00592 oxSession::setVar( "malladmin", 0);
00593 oxSession::setVar( "blIsAdmin", 0);
00594 oxSession::deleteVar( "blIsAdmin" );
00595 $myConfig->setConfigParam( 'blMallAdmin', false );
00596
00597 $myConfig->setConfigParam( 'blAllowInheritedEdit', false );
00598
00599 if ( $sUserID) {
00600
00601 $oDb = oxDb::getDb();
00602 $sUserID = $oDb->Quote($sUserID);
00603 $sRights = $oDb->GetOne("select oxrights from oxuser where oxid = $sUserID");
00604
00605 if ( $sRights != "user") {
00606
00607 if ( $sRights == "malladmin") {
00608 oxSession::setVar( "malladmin", 1);
00609 $myConfig->setConfigParam( 'blMallAdmin', true );
00610
00611
00612
00613 $myConfig->setConfigParam( 'blAllowSharedEdit', true );
00614
00615 $sShop = oxSession::getVar( "actshop");
00616 if ( !isset($sShop)) {
00617 oxSession::setVar( "actshop", $myConfig->getBaseShopId());
00618 }
00619 $blIsAuth = true;
00620 } else {
00621 $sShopID = $oDb->GetOne("select oxid from oxshops where oxid = '{$sRights}'");
00622 if ( isset( $sShopID) && $sShopID) {
00623
00624 oxSession::setVar( "actshop", $sRights);
00625 oxSession::setVar( "currentadminshop", $sRights);
00626 oxSession::setVar( "shp", $sRights);
00627
00628
00629 if ('chshp' == oxConfig::getParameter( 'fnc' )) {
00630
00631 $blIsAuth = false;
00632 } else {
00633 $blIsAuth = true;
00634
00635 $aShopIdVars = array('actshop', 'shp', 'currentadminshop');
00636 foreach ($aShopIdVars as $sShopIdVar) {
00637 if ($sGotShop = oxConfig::getParameter( $sShopIdVar )) {
00638 if ($sGotShop != $sRights) {
00639 $blIsAuth = false;
00640 break;
00641 }
00642 }
00643 }
00644 }
00645 }
00646 }
00647
00648 oxSession::setVar( "blIsAdmin", 1);
00649 }
00650 }
00651 return $blIsAuth;
00652 }
00653
00663 public function seoIsActive( $blReset = false, $sShopId = null, $iActLang = null )
00664 {
00665 if ( !is_null( $this->_blSeoIsActive ) && !$blReset ) {
00666 return $this->_blSeoIsActive;
00667 }
00668
00669 $myConfig = $this->getConfig();
00670
00671 if ( $this->isAdmin() ) {
00672
00673 $this->_blSeoIsActive = false;
00674 } elseif ( ( $this->_blSeoIsActive = $myConfig->getConfigParam( 'blSeoMode' ) ) === null ) {
00675 $this->_blSeoIsActive = true;
00676
00677 $aSeoModes = $myConfig->getconfigParam( 'aSeoModes' );
00678 $sActShopId = $sShopId ? $sShopId : $myConfig->getActiveShop()->getId();
00679 $iActLang = $iActLang ? $iActLang : (int) oxLang::getInstance()->getBaseLanguage();
00680
00681
00682 if ( is_array( $aSeoModes ) && isset( $aSeoModes[$sActShopId] ) && isset( $aSeoModes[$sActShopId][$iActLang] ) ) {
00683 $this->_blSeoIsActive = (bool) $aSeoModes[$sActShopId][$iActLang];
00684 }
00685 }
00686
00687 return $this->_blSeoIsActive;
00688 }
00689
00699 public function getShopBit( $iShopId )
00700 {
00701 $iShopId = (int) $iShopId;
00702
00703 $iRes = oxDb::getDb()->getOne( "select 1 << ( $iShopId - 1 ) as shopbit" );
00704
00705
00706 return $iRes;
00707 }
00708
00718 public function bitwiseAnd( $iVal1, $iVal2 )
00719 {
00720
00721 $iRes = oxDb::getDb()->getOne( "select ($iVal1 & $iVal2) as bitwiseAnd" );
00722
00723
00724 return $iRes;
00725 }
00726
00736 public function bitwiseOr( $iVal1, $iVal2 )
00737 {
00738
00739 $iRes = oxDb::getDb()->getOne( "select ($iVal1 | $iVal2) as bitwiseOr" );
00740
00741
00742 return $iRes;
00743 }
00744
00752 public function isValidAlpha( $sField )
00753 {
00754 return (boolean) preg_match( "#^[\w]*$#", $sField );
00755 }
00756
00766 protected function _simpleRedirect( $sUrl, $sHeaderCode )
00767 {
00768 header( $sHeaderCode );
00769 header( "Location: $sUrl" );
00770 header( "Connection: close" );
00771 }
00772
00781 public function redirect( $sUrl, $blAddRedirectParam = true )
00782 {
00783
00784
00785 if ( $blAddRedirectParam && oxConfig::getParameter( 'redirected' ) ) {
00786 return;
00787 }
00788
00789 if ( $blAddRedirectParam ) {
00790 $sUrl = $this->_addUrlParameters( $sUrl, array( 'redirected' => 1 ) );
00791 }
00792
00793 $sUrl = str_ireplace( "&", "&", $sUrl );
00794 $this->_simpleRedirect( $sUrl, "HTTP/1.1 301 Moved Permanently" );
00795
00796 try {
00797 $this->getSession()->freeze();
00798 } catch( oxException $oEx ) {
00799 $oEx->debugOut();
00800
00801 }
00802
00803 if ( defined( 'OXID_PHP_UNIT' ) ) {
00804 return;
00805 }
00806
00807 $this->showMessageAndExit( '' );
00808 }
00809
00817 public function showMessageAndExit( $sMsg )
00818 {
00819 $this->getSession()->freeze();
00820
00821 if ( defined( 'OXID_PHP_UNIT' ) ) {
00822 return;
00823 }
00824
00825 die( $sMsg );
00826 }
00827
00836 protected function _addUrlParameters( $sUrl, $aParams )
00837 {
00838 $sDelim = ( ( getStr()->strpos( $sUrl, '?' ) !== false ) )?'&':'?';
00839 foreach ( $aParams as $sName => $sVal ) {
00840 $sUrl = $sUrl . $sDelim . $sName . '=' . $sVal;
00841 $sDelim = '&';
00842 }
00843
00844 return $sUrl;
00845 }
00846
00858 protected function _fillExplodeArray( $aName, $dVat = null)
00859 {
00860 $myConfig = $this->getConfig();
00861 $oObject = new OxstdClass();
00862 $aPrice = explode( '!P!', $aName[0]);
00863
00864 if ( ( $myConfig->getConfigParam( 'bl_perfLoadSelectLists' ) && $myConfig->getConfigParam( 'bl_perfUseSelectlistPrice' ) && isset( $aPrice[0] ) && isset( $aPrice[1] ) ) || $this->isAdmin() ) {
00865
00866
00867 $oObject->price = $aPrice[1];
00868 $aName[0] = $aPrice[0];
00869
00870 $iPercPos = getStr()->strpos( $oObject->price, '%' );
00871 if ( $iPercPos !== false ) {
00872 $oObject->priceUnit = '%';
00873 $oObject->fprice = $oObject->price;
00874 $oObject->price = substr( $oObject->price, 0, $iPercPos );
00875 } else {
00876 $oCur = $myConfig->getActShopCurrencyObject();
00877 $oObject->price = str_replace(',', '.', $oObject->price);
00878 $oObject->fprice = oxLang::getInstance()->formatCurrency( $oObject->price * $oCur->rate, $oCur);
00879 $oObject->priceUnit = 'abs';
00880 }
00881
00882
00883 if ( !$this->isAdmin() ) {
00884 $aName[0] .= " ";
00885 if ( $oObject->price > 0 ) {
00886 $aName[0] .= "+";
00887 }
00888
00889 if ( $dVat != null && $oObject->priceUnit == 'abs' ) {
00890 $oPrice = oxNew('oxPrice');
00891 $oPrice->setPrice($oObject->price, $dVat);
00892 $aName[0] .= oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() * $oCur->rate, $oCur);
00893 } else {
00894 $aName[0] .= $oObject->fprice;
00895 }
00896 if ( $oObject->priceUnit == 'abs' ) {
00897 $aName[0] .= " ".$oCur->sign;
00898 }
00899 }
00900 } elseif ( isset( $aPrice[0] ) && isset($aPrice[1] ) ) {
00901
00902 $aName[0] = ereg_replace( "!P!.*", "", $aName[0] );
00903 }
00904
00905 $oObject->name = $aName[0];
00906 $oObject->value = $aName[1];
00907 return $oObject;
00908 }
00909
00917 public function oxMimeContentType( $sFileName )
00918 {
00919 $sFileName = strtolower( $sFileName );
00920 $iLastDot = strrpos( $sFileName, '.' );
00921
00922 if ( $iLastDot !== false ) {
00923 $sType = substr( $sFileName, $iLastDot + 1 );
00924 switch ( $sType ) {
00925 case 'gif':
00926 $sType = 'image/gif';
00927 break;
00928 case 'jpeg':
00929 case 'jpg':
00930 $sType = 'image/jpeg';
00931 break;
00932 case 'png':
00933 $sType = 'image/png';
00934 break;
00935 default:
00936 $sType = false;
00937 break;
00938 }
00939 }
00940 return $sType;
00941 }
00942
00951 public function logger( $sText, $blNewline = false )
00952 { $myConfig = $this->getConfig();
00953
00954 if ( $myConfig->getConfigParam( 'iDebug' ) == -2) {
00955 if ( gettype( $sText ) != 'string' ) {
00956 $sText = var_export( $sText, true);
00957 }
00958 @error_log("----------------------------------------------\n$sText".( ( $blNewline ) ?"\n":"" )."\n", 3, $myConfig->getConfigParam( 'sCompileDir' ).'/log.txt' );
00959 }
00960
00961 }
00962
00970 protected function _stripQuotes($mInput)
00971 {
00972 return is_array($mInput) ? array_map( array( $this, '_stripQuotes' ), $mInput) : stripslashes( $mInput );
00973 }
00974
00982 public function strRot13( $sStr )
00983 {
00984 $sFrom = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
00985 $sTo = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM';
00986
00987 return strtr( $sStr, $sFrom, $sTo );
00988 }
00989
00990
01000 public function prepareUrlForNoSession($sUrl)
01001 {
01002 if ( $this->seoIsActive() ) {
01003 return $sUrl;
01004 }
01005
01006 $sUrl = preg_replace('/(force_)?sid=[a-z0-9\._]*&?(amp;)?/i', '', $sUrl);
01007
01008 $oStr = getStr();
01009 if ($qpos = $oStr->strpos($sUrl, '?')) {
01010 if ($qpos == $oStr->strlen($sUrl)-1) {
01011 $sSep = '';
01012 } else {
01013 $sSep = '&';
01014 }
01015 } else {
01016 $sSep = '?';
01017 }
01018
01019 if (!preg_match('/[&?](amp;)?lang=[0-9]+/i', $sUrl)) {
01020 $sUrl .= "{$sSep}lang=".oxLang::getInstance()->getBaseLanguage();
01021 $sSep = '&';
01022 }
01023
01024 if (!preg_match('/[&?](amp;)?cur=[0-9]+/i', $sUrl)) {
01025 $iCur = (int) oxConfig::getParameter('currency');
01026 if ($iCur) {
01027 $sUrl .= "{$sSep}cur=".$iCur;
01028 $sSep = '&';
01029 }
01030 }
01031
01032 return $sUrl;
01033 }
01034
01042 protected function _getCacheFilePath( $sCacheName )
01043 {
01044 $sVersionPrefix = "";
01045
01046
01047 $sVersionPrefix = 'pe';
01048
01049 return $this->getConfig()->getConfigParam( 'sCompileDir' ) . "/ox{$sVersionPrefix}c_{$sCacheName}.txt";
01050 }
01051
01059 public function getLangCache( $sCacheName )
01060 {
01061 $aLangCache = null;
01062 $sFilePath = $this->_getCacheFilePath( $sCacheName );
01063 if ( file_exists( $sFilePath ) && is_readable( $sFilePath ) ) {
01064 include( $sFilePath );
01065 }
01066 return $aLangCache;
01067 }
01068
01077 public function setLangCache( $sCacheName, $aLangCache )
01078 {
01079 $sCache = "<?php\n\$aLangCache = ".var_export( $aLangCache, true ).";";
01080 $this->_oxFileCache( true, $sCacheName, $sCache );
01081 }
01082
01090 public function checkUrlEndingSlash( $sUrl )
01091 {
01092 if ( !preg_match("/\/$/", $sUrl) ) {
01093 $sUrl .= '/';
01094 }
01095
01096 return $sUrl;
01097 }
01098
01099 }