00001 <?php
00002
00006 require_once getShopBasePath()."core/smarty/Smarty.class.php";
00007
00012 class oxUtils extends oxSuperCfg
00013 {
00019 private static $_instance = null;
00020
00026 protected $_iCurPrecision = null;
00027
00033 protected $_sEmailTpl = "^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~\177])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~\177]+\\.)+[a-zA-Z]{2,6}\$";
00034
00042 protected $_sPermanentCachePattern = "/c_fieldnames_/";
00043
00049 public static function getInstance()
00050 {
00051
00052 if ( defined( 'OXID_PHP_UNIT' ) ) {
00053 static $inst = array();
00054 self::$_instance = $inst[oxClassCacheKey()];
00055
00056 }
00057
00058 if ( !self::$_instance instanceof oxUtils ) {
00059
00060
00061 self::$_instance = oxNew( 'oxUtils' );
00062
00063 if ( defined( 'OXID_PHP_UNIT' ) ) {
00064 $inst[oxClassCacheKey()] = self::$_instance;
00065 }
00066 }
00067 return self::$_instance;
00068 }
00069
00075 protected $_aStaticCache;
00076
00082 protected $_blSeoIsActive = null;
00083
00089 public function stripGpcMagicQuotes()
00090 {
00091 if (!get_magic_quotes_gpc()) {
00092 return;
00093 }
00094 $_REQUEST = self::_stripQuotes($_REQUEST);
00095 $_POST = self::_stripQuotes($_POST);
00096 $_GET = self::_stripQuotes($_GET);
00097 $_COOKIE = self::_stripQuotes($_COOKIE);
00098 }
00099
00108 public function strMan( $sVal, $sKey = null )
00109 {
00110 $sKey = $sKey?$sKey:'oxid123456789';
00111 $sVal = "ox{$sVal}id";
00112
00113 $sKey = str_repeat( $sKey, strlen( $sVal ) / strlen( $sKey ) + 5 );
00114 $sVal = $this->strRot13( $sVal );
00115 $sVal = $sVal ^ $sKey;
00116 $sVal = base64_encode( $sVal );
00117 $sVal = str_replace( "=", "!", $sVal );
00118
00119 return "ox_$sVal";
00120 }
00121
00130 public function strRem( $sVal, $sKey = null )
00131 {
00132 $sKey = $sKey?$sKey:'oxid123456789';
00133 $sKey = str_repeat( $sKey, strlen( $sVal ) / strlen( $sKey ) + 5 );
00134
00135 $sVal = substr( $sVal, 3 );
00136 $sVal = str_replace( '!', '=', $sVal );
00137 $sVal = base64_decode( $sVal );
00138 $sVal = $sVal ^ $sKey;
00139 $sVal = $this->strRot13( $sVal );
00140
00141 return substr( $sVal, 2, -2 );
00142 }
00143
00151 public function getArrFldName( $sName)
00152 {
00153 return str_replace( ".", "__", $sName);
00154 }
00155
00164 public function assignValuesFromText( $sIn, $dVat = null)
00165 {
00166 $aRet = array();
00167 $aPieces = explode( '@@', $sIn );
00168 while ( list( $sKey, $sVal ) = each( $aPieces ) ) {
00169 if ( $sVal ) {
00170 $aName = explode( '__', $sVal );
00171 if ( isset( $aName[0] ) && isset( $aName[1] ) ) {
00172 $aRet[] = $this->_fillExplodeArray( $aName, $dVat );
00173 }
00174 }
00175 }
00176 return $aRet;
00177 }
00178
00186 public function assignValuesToText( $aIn)
00187 {
00188 $sRet = "";
00189 reset( $aIn );
00190 while (list($sKey, $sVal) = each($aIn)) {
00191 $sRet .= $sKey;
00192 $sRet .= "__";
00193 $sRet .= $sVal;
00194 $sRet .= "@@";
00195 }
00196 return $sRet;
00197 }
00198
00207 public function formatCurrency( $dValue, $oActCur = null )
00208 {
00209 if (!$oActCur) {
00210 $oActCur = $this->getConfig()->getActShopCurrencyObject();
00211 }
00212 $sFormated = number_format( $dValue, $oActCur->decimal, $oActCur->dec, $oActCur->thousand);
00213
00214 return $sFormated;
00215 }
00216
00224 public function currency2Float( $sValue)
00225 {
00226 $fRet = $sValue;
00227 $iPos = strrpos( $sValue, ".");
00228 if ($iPos && ((strlen($sValue)-1-$iPos) < 2+1)) {
00229
00230 $fRet = substr_replace( $fRet, ",", $iPos, 1);
00231 }
00232
00233 $fRet = str_replace( array(" ","."), "", $fRet);
00234
00235 $fRet = str_replace( ",", ".", $fRet);
00236 return (float) $fRet;
00237 }
00238
00246 public function isSearchEngine( $sClient = null )
00247 {
00248 $myConfig = $this->getConfig();
00249 $blIsSe = false;
00250
00251 if ( !( $myConfig->getConfigParam( 'iDebug' ) && $this->isAdmin() ) ) {
00252
00253
00254 $blIsSe = $myConfig->getGlobalParameter( 'blIsSearchEngine' );
00255 if ( !isset( $blIsSe ) ) {
00256
00257 $aRobots = $myConfig->getConfigParam( 'aRobots' );
00258 $aRobots = is_array( $aRobots )?$aRobots:array();
00259
00260 $aRobotsExcept = $myConfig->getConfigParam( 'aRobotsExcept' );
00261 $aRobotsExcept = is_array( $aRobotsExcept )?$aRobotsExcept:array();
00262
00263 $sClient = $sClient?$sClient:strtolower( getenv( 'HTTP_USER_AGENT' ) );
00264 $blIsSe = false;
00265 $aRobots = array_merge( $aRobots, $aRobotsExcept );
00266 foreach ( $aRobots as $sRobot ) {
00267 if ( strpos( $sClient, $sRobot ) !== false ) {
00268 $blIsSe = true;
00269 break;
00270 }
00271 }
00272 $myConfig->setGlobalParameter( 'blIsSearchEngine', $blIsSe );
00273 }
00274 }
00275
00276 return $blIsSe;
00277 }
00278
00287 public function isValidEmail( $sEmail )
00288 {
00289 $blValid = true;
00290 if ( $sEmail != 'admin' ) {
00291 $blValid = ( eregi( $this->_sEmailTpl, $sEmail ) != 0 );
00292 }
00293
00294 return $blValid;
00295 }
00296
00302 public function rebuildCache()
00303 {
00304
00305
00306
00307
00308
00309 if ( function_exists( "UserdefinedRebuildCache")) {
00310 UserdefinedRebuildCache();
00311 }
00312 }
00313
00321 public function loadAdminProfile($aInterfaceProfiles)
00322 {
00323
00324
00325 $aInterfaceProfiles = $aInterfaceProfiles;
00326 if ( is_array( $aInterfaceProfiles ) ) {
00327 $sPrevProfile = oxUtilsServer::getInstance()->getOxCookie('oxidadminprofile');
00328 if (isset($sPrevProfile)) {
00329 $aPrevProfile = @explode("@", trim($sPrevProfile));
00330 }
00331
00332
00333 $aProfiles = array();
00334 foreach ( $aInterfaceProfiles as $iPos => $sProfile) {
00335 $aProfileSettings = array($iPos, $sProfile);
00336 $aProfiles[] = $aProfileSettings;
00337 }
00338
00339 if (isset($aPrevProfile[0]) && isset($aProfiles[$aPrevProfile[0]])) {
00340 $aProfiles[$aPrevProfile[0]][2] = 1;
00341 }
00342
00343 oxSession::setVar("aAdminProfiles", $aProfiles);
00344 return $aProfiles;
00345 }
00346 return null;
00347 }
00348
00357 public function fRound($sVal, $oCur = null)
00358 {
00359 startProfile('fround');
00360
00361
00362 $iCurPrecision = null;
00363 if (! defined('OXID_PHP_UNIT')) {
00364 $iCurPrecision = $this->_iCurPrecision;
00365 }
00366
00367 if (is_null($iCurPrecision)) {
00368 if ( !$oCur ) {
00369 $oCur = $this->getConfig()->getActShopCurrencyObject();
00370 }
00371
00372 $iCurPrecision = $oCur->decimal;
00373 $this->_iCurPrecision = $iCurPrecision;
00374 }
00375
00376
00377 static $dprez = null;
00378 if (!$dprez) {
00379 $prez = @ini_get("precision");
00380 if (!$prez) {
00381 $prez = 9;
00382 }
00383 $dprez = pow(10, -$prez);
00384 }
00385
00386
00387 stopProfile('fround');
00388
00389 return round($sVal + $dprez, $iCurPrecision);
00390 }
00391
00401 public function toStaticCache( $sName, $sContent, $sKey = null )
00402 {
00403
00404 if ( $sKey ) {
00405 $this->_aStaticCache[$sName][$sKey] = $sContent;
00406 } else {
00407 $this->_aStaticCache[$sName] = $sContent;
00408 }
00409 }
00410
00418 public function fromStaticCache( $sName)
00419 {
00420 if ( isset( $this->_aStaticCache[$sName])) {
00421 return $this->_aStaticCache[$sName];
00422 }
00423 return null;
00424 }
00425
00433 public function cleanStaticCache($sCacheName = null)
00434 {
00435 if ($sCacheName) {
00436 unset($this->_aStaticCache[$sCacheName]);
00437 } else {
00438 $this->_aStaticCache = null;
00439 }
00440 }
00441
00451 protected function _oxFileCache( $blMode, $sName, $sInput = null )
00452 {
00453 $sFilePath = $this->_getCacheFilePath( $sName );
00454 $sRet = null;
00455 if ( $blMode) {
00456
00457
00458
00459
00460
00461 $hFile = fopen( $sFilePath, "w");
00462 if ( $hFile) {
00463 fwrite( $hFile, $sInput);
00464 fclose( $hFile);
00465 }
00466 } else {
00467 if ( file_exists( $sFilePath) && is_readable($sFilePath)) {
00468
00469 $sRet = file_get_contents( $sFilePath);
00470 }
00471 }
00472 return $sRet;
00473 }
00474
00483 public function toFileCache($sKey, $sContents)
00484 {
00485 $sStaticCacheKey = 'staticfilecache|' . $sKey;
00486 $this->toStaticCache($sStaticCacheKey, $sContents);
00487
00488 $sContents = serialize($sContents);
00489 return $this->_oxFileCache(true, $sKey, $sContents);
00490 }
00491
00499 public function fromFileCache( $sKey )
00500 {
00501 $sStaticCacheKey = "staticfilecache|$sKey";
00502
00503
00504 $sRes = $this->fromStaticCache( $sStaticCacheKey );
00505
00506 if ( is_null( $sRes ) ) {
00507 $sRes = $this->_oxFileCache( false, $sKey );
00508 if (!is_null($sRes)) {
00509 $sRes = unserialize( $sRes );
00510 $this->toStaticCache( $sStaticCacheKey, $sRes );
00511 }
00512 }
00513
00514 return $sRes;
00515 }
00516
00524 public function oxResetFileCache()
00525 {
00526 $aPathes = glob( $this->_getCacheFilePath( null, true ) . '*' );
00527 if ( is_array( $aPathes ) ) {
00528
00529 $aPathes = preg_grep( $this->_sPermanentCachePattern, $aPathes, PREG_GREP_INVERT );
00530 foreach ( $aPathes as $sFilename ) {
00531 @unlink( $sFilename );
00532 }
00533 }
00534 }
00535
00545 public function getRemoteCachePath($sRemote, $sLocal)
00546 {
00547 clearstatcache();
00548 if ( file_exists( $sLocal ) && filemtime( $sLocal ) && filemtime( $sLocal ) > time() - 86400 ) {
00549 return $sLocal;
00550 }
00551 $hRemote = @fopen( $sRemote, "rb");
00552 $blSuccess = false;
00553 if ( isset( $hRemote) && $hRemote ) {
00554 $hLocal = fopen( $sLocal, "wb");
00555 stream_copy_to_stream($hRemote, $hLocal);
00556 fclose($hRemote);
00557 fclose($hLocal);
00558 $blSuccess = true;
00559 } else {
00560
00561 $aUrl = @parse_url( $sRemote);
00562 if ( !empty( $aUrl["host"])) {
00563 $sPath = $aUrl["path"];
00564 if ( empty( $sPath ) ) {
00565 $sPath = "/";
00566 }
00567 $sHost = $aUrl["host"];
00568
00569 $hSocket = @fsockopen( $sHost, 80, $iErrorNumber, $iErrStr, 5);
00570 if ( $hSocket) {
00571 fputs( $hSocket, "GET ".$sPath." HTTP/1.0\r\nHost: $sHost\r\n\r\n");
00572 $headers = stream_get_line($hSocket, 4096, "\r\n\r\n");
00573 $hLocal = @fopen( $sLocal, "wb");
00574 stream_copy_to_stream($hSocket, $hLocal);
00575 fclose( $hSocket);
00576 fclose($hLocal);
00577 $blSuccess = true;
00578 }
00579 }
00580 }
00581 if ( $blSuccess || file_exists( $sLocal ) ) {
00582 return $sLocal;
00583 } else {
00584 return false;
00585 }
00586 }
00587
00593 public function checkAccessRights()
00594 {
00595 $myConfig = $this->getConfig();
00596
00597 $blIsAuth = false;
00598
00599 $sUserID = oxSession::getVar( "auth");
00600
00601
00602 oxSession::setVar( "malladmin", 0);
00603 oxSession::setVar( "blIsAdmin", 0);
00604 oxSession::deleteVar( "blIsAdmin" );
00605 $myConfig->setConfigParam( 'blMallAdmin', false );
00606
00607 $myConfig->setConfigParam( 'blAllowInheritedEdit', false );
00608
00609 if ( $sUserID) {
00610
00611 $oDb = oxDb::getDb();
00612 $sUserID = $oDb->quote($sUserID);
00613 $sRights = $oDb->getOne("select oxrights from oxuser where oxid = $sUserID");
00614
00615 if ( $sRights != "user") {
00616
00617 if ( $sRights == "malladmin") {
00618 oxSession::setVar( "malladmin", 1);
00619 $myConfig->setConfigParam( 'blMallAdmin', true );
00620
00621
00622
00623 $myConfig->setConfigParam( 'blAllowSharedEdit', true );
00624
00625 $sShop = oxSession::getVar( "actshop");
00626 if ( !isset($sShop)) {
00627 oxSession::setVar( "actshop", $myConfig->getBaseShopId());
00628 }
00629 $blIsAuth = true;
00630 } else {
00631 $sShopID = $oDb->getOne("select oxid from oxshops where oxid = '{$sRights}'");
00632 if ( isset( $sShopID) && $sShopID) {
00633
00634 oxSession::setVar( "actshop", $sRights);
00635 oxSession::setVar( "currentadminshop", $sRights);
00636 oxSession::setVar( "shp", $sRights);
00637
00638
00639 if ('chshp' == oxConfig::getParameter( 'fnc' )) {
00640
00641 $blIsAuth = false;
00642 } else {
00643 $blIsAuth = true;
00644
00645 $aShopIdVars = array('actshop', 'shp', 'currentadminshop');
00646 foreach ($aShopIdVars as $sShopIdVar) {
00647 if ($sGotShop = oxConfig::getParameter( $sShopIdVar )) {
00648 if ($sGotShop != $sRights) {
00649 $blIsAuth = false;
00650 break;
00651 }
00652 }
00653 }
00654 }
00655 }
00656 }
00657
00658 oxSession::setVar( "blIsAdmin", 1);
00659 }
00660 }
00661 return $blIsAuth;
00662 }
00663
00673 public function seoIsActive( $blReset = false, $sShopId = null, $iActLang = null )
00674 {
00675 if ( !is_null( $this->_blSeoIsActive ) && !$blReset ) {
00676 return $this->_blSeoIsActive;
00677 }
00678
00679 $myConfig = $this->getConfig();
00680
00681 if ( $this->isAdmin() ) {
00682
00683 $this->_blSeoIsActive = false;
00684 } elseif ( ( $this->_blSeoIsActive = $myConfig->getConfigParam( 'blSeoMode' ) ) === null ) {
00685 $this->_blSeoIsActive = true;
00686
00687 $aSeoModes = $myConfig->getconfigParam( 'aSeoModes' );
00688 $sActShopId = $sShopId ? $sShopId : $myConfig->getActiveShop()->getId();
00689 $iActLang = $iActLang ? $iActLang : (int) oxLang::getInstance()->getBaseLanguage();
00690
00691
00692 if ( is_array( $aSeoModes ) && isset( $aSeoModes[$sActShopId] ) && isset( $aSeoModes[$sActShopId][$iActLang] ) ) {
00693 $this->_blSeoIsActive = (bool) $aSeoModes[$sActShopId][$iActLang];
00694 }
00695 }
00696
00697 return $this->_blSeoIsActive;
00698 }
00699
00709 public function getShopBit( $iShopId )
00710 {
00711 $iShopId = (int) $iShopId;
00712
00713 $iRes = oxDb::getDb()->getOne( "select 1 << ( $iShopId - 1 ) as shopbit" );
00714
00715
00716 return $iRes;
00717 }
00718
00728 public function bitwiseAnd( $iVal1, $iVal2 )
00729 {
00730
00731 $iRes = oxDb::getDb()->getOne( "select ($iVal1 & $iVal2) as bitwiseAnd" );
00732
00733
00734 return $iRes;
00735 }
00736
00746 public function bitwiseOr( $iVal1, $iVal2 )
00747 {
00748
00749 $iRes = oxDb::getDb()->getOne( "select ($iVal1 | $iVal2) as bitwiseOr" );
00750
00751
00752 return $iRes;
00753 }
00754
00762 public function isValidAlpha( $sField )
00763 {
00764 return (boolean) preg_match( "#^[\w]*$#", $sField );
00765 }
00766
00776 protected function _simpleRedirect( $sUrl, $sHeaderCode )
00777 {
00778 header( $sHeaderCode );
00779 header( "Location: $sUrl" );
00780 header( "Connection: close" );
00781 }
00782
00791 public function redirect( $sUrl, $blAddRedirectParam = true )
00792 {
00793
00794
00795 if ( $blAddRedirectParam && oxConfig::getParameter( 'redirected' ) ) {
00796 return;
00797 }
00798
00799 if ( $blAddRedirectParam ) {
00800 $sUrl = $this->_addUrlParameters( $sUrl, array( 'redirected' => 1 ) );
00801 }
00802
00803 $sUrl = str_ireplace( "&", "&", $sUrl );
00804 $this->_simpleRedirect( $sUrl, "HTTP/1.1 301 Moved Permanently" );
00805
00806 try {
00807 $this->getSession()->freeze();
00808 } catch( oxException $oEx ) {
00809 $oEx->debugOut();
00810
00811 }
00812
00813 if ( defined( 'OXID_PHP_UNIT' ) ) {
00814 return;
00815 }
00816
00817 $this->showMessageAndExit( '' );
00818 }
00819
00827 public function showMessageAndExit( $sMsg )
00828 {
00829 $this->getSession()->freeze();
00830
00831 if ( defined( 'OXID_PHP_UNIT' ) ) {
00832 return;
00833 }
00834
00835 die( $sMsg );
00836 }
00837
00846 protected function _addUrlParameters( $sUrl, $aParams )
00847 {
00848 $sDelim = ( ( getStr()->strpos( $sUrl, '?' ) !== false ) )?'&':'?';
00849 foreach ( $aParams as $sName => $sVal ) {
00850 $sUrl = $sUrl . $sDelim . $sName . '=' . $sVal;
00851 $sDelim = '&';
00852 }
00853
00854 return $sUrl;
00855 }
00856
00868 protected function _fillExplodeArray( $aName, $dVat = null)
00869 {
00870 $myConfig = $this->getConfig();
00871 $oObject = new OxstdClass();
00872 $aPrice = explode( '!P!', $aName[0]);
00873
00874 if ( ( $myConfig->getConfigParam( 'bl_perfLoadSelectLists' ) && $myConfig->getConfigParam( 'bl_perfUseSelectlistPrice' ) && isset( $aPrice[0] ) && isset( $aPrice[1] ) ) || $this->isAdmin() ) {
00875
00876
00877 $oObject->price = $aPrice[1];
00878 $aName[0] = $aPrice[0];
00879
00880 $iPercPos = getStr()->strpos( $oObject->price, '%' );
00881 if ( $iPercPos !== false ) {
00882 $oObject->priceUnit = '%';
00883 $oObject->fprice = $oObject->price;
00884 $oObject->price = substr( $oObject->price, 0, $iPercPos );
00885 } else {
00886 $oCur = $myConfig->getActShopCurrencyObject();
00887 $oObject->price = str_replace(',', '.', $oObject->price);
00888 $oObject->fprice = oxLang::getInstance()->formatCurrency( $oObject->price * $oCur->rate, $oCur);
00889 $oObject->priceUnit = 'abs';
00890 }
00891
00892
00893 if ( !$this->isAdmin() && $oObject->price != 0 ) {
00894 $aName[0] .= " ";
00895 if ( $oObject->price > 0 ) {
00896 $aName[0] .= "+";
00897 }
00898
00899 if ( $dVat != null && $oObject->priceUnit == 'abs' ) {
00900 $oPrice = oxNew('oxPrice');
00901 $oPrice->setPrice($oObject->price, $dVat);
00902 $aName[0] .= oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() * $oCur->rate, $oCur);
00903 } else {
00904 $aName[0] .= $oObject->fprice;
00905 }
00906 if ( $oObject->priceUnit == 'abs' ) {
00907 $aName[0] .= " ".$oCur->sign;
00908 }
00909 }
00910 } elseif ( isset( $aPrice[0] ) && isset($aPrice[1] ) ) {
00911
00912 $aName[0] = ereg_replace( "!P!.*", "", $aName[0] );
00913 }
00914
00915 $oObject->name = $aName[0];
00916 $oObject->value = $aName[1];
00917 return $oObject;
00918 }
00919
00927 public function oxMimeContentType( $sFileName )
00928 {
00929 $sFileName = strtolower( $sFileName );
00930 $iLastDot = strrpos( $sFileName, '.' );
00931
00932 if ( $iLastDot !== false ) {
00933 $sType = substr( $sFileName, $iLastDot + 1 );
00934 switch ( $sType ) {
00935 case 'gif':
00936 $sType = 'image/gif';
00937 break;
00938 case 'jpeg':
00939 case 'jpg':
00940 $sType = 'image/jpeg';
00941 break;
00942 case 'png':
00943 $sType = 'image/png';
00944 break;
00945 default:
00946 $sType = false;
00947 break;
00948 }
00949 }
00950 return $sType;
00951 }
00952
00961 public function logger( $sText, $blNewline = false )
00962 { $myConfig = $this->getConfig();
00963
00964 if ( $myConfig->getConfigParam( 'iDebug' ) == -2) {
00965 if ( gettype( $sText ) != 'string' ) {
00966 $sText = var_export( $sText, true);
00967 }
00968 @error_log("----------------------------------------------\n$sText".( ( $blNewline ) ?"\n":"" )."\n", 3, $myConfig->getConfigParam( 'sCompileDir' ).'/log.txt' );
00969 }
00970
00971 }
00972
00980 protected function _stripQuotes($mInput)
00981 {
00982 return is_array($mInput) ? array_map( array( $this, '_stripQuotes' ), $mInput) : stripslashes( $mInput );
00983 }
00984
00992 public function strRot13( $sStr )
00993 {
00994 $sFrom = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
00995 $sTo = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM';
00996
00997 return strtr( $sStr, $sFrom, $sTo );
00998 }
00999
01000
01010 public function prepareUrlForNoSession($sUrl)
01011 {
01012 if ( $this->seoIsActive() ) {
01013 return $sUrl;
01014 }
01015
01016 $sUrl = preg_replace('/(force_)?sid=[a-z0-9\._]*&?(amp;)?/i', '', $sUrl);
01017
01018 $oStr = getStr();
01019 if ($qpos = $oStr->strpos($sUrl, '?')) {
01020 if ($qpos == $oStr->strlen($sUrl)-1) {
01021 $sSep = '';
01022 } else {
01023 $sSep = '&';
01024 }
01025 } else {
01026 $sSep = '?';
01027 }
01028
01029 if (!preg_match('/[&?](amp;)?lang=[0-9]+/i', $sUrl)) {
01030 $sUrl .= "{$sSep}lang=".oxLang::getInstance()->getBaseLanguage();
01031 $sSep = '&';
01032 }
01033
01034 if (!preg_match('/[&?](amp;)?cur=[0-9]+/i', $sUrl)) {
01035 $iCur = (int) oxConfig::getParameter('currency');
01036 if ($iCur) {
01037 $sUrl .= "{$sSep}cur=".$iCur;
01038 $sSep = '&';
01039 }
01040 }
01041
01042 return $sUrl;
01043 }
01044
01053 protected function _getCacheFilePath( $sCacheName, $blPathOnly = false )
01054 {
01055 $sVersionPrefix = "";
01056
01057
01058 $sVersionPrefix = 'pe';
01059
01060 $sPath = $this->getConfig()->getConfigParam( 'sCompileDir' );
01061 return $blPathOnly ? "{$sPath}/" : "{$sPath}/ox{$sVersionPrefix}c_{$sCacheName}.txt";
01062 }
01063
01071 public function getLangCache( $sCacheName )
01072 {
01073 $aLangCache = null;
01074 $sFilePath = $this->_getCacheFilePath( $sCacheName );
01075 if ( file_exists( $sFilePath ) && is_readable( $sFilePath ) ) {
01076 include $sFilePath;
01077 }
01078 return $aLangCache;
01079 }
01080
01089 public function setLangCache( $sCacheName, $aLangCache )
01090 {
01091 $sCache = "<?php\n\$aLangCache = ".var_export( $aLangCache, true ).";";
01092 $this->_oxFileCache( true, $sCacheName, $sCache );
01093 }
01094
01102 public function checkUrlEndingSlash( $sUrl )
01103 {
01104 if ( !preg_match("/\/$/", $sUrl) ) {
01105 $sUrl .= '/';
01106 }
01107
01108 return $sUrl;
01109 }
01110
01111 }