00001 <?php
00002
00003 define( 'MAX_64BIT_INTEGER', '18446744073709551615' );
00004
00009 class oxConfig extends oxSuperCfg
00010 {
00011
00012
00013
00019 protected $dbHost = null;
00020
00026 protected $dbName = null;
00027
00033 protected $dbUser = null;
00034
00040 protected $dbPwd = null;
00041
00047 protected $dbType = null;
00048
00054 protected $sShopURL = null;
00055
00061 protected $sSSLShopURL = null;
00062
00068 protected $sAdminSSLURL = null;
00069
00075 protected $sShopDir = null;
00076
00082 protected $sCompileDir = null;
00083
00098 protected $iDebug = 0;
00099
00105 protected $sAdminEmail = null;
00106
00112 protected $blSessionUseCookies = null;
00113
00119
00120
00130 protected $blNativeImages = true;
00131
00137 protected $aMultiShopTables = array( 'oxarticles', 'oxdiscount', 'oxcategories', 'oxattribute',
00138 'oxlinks', 'oxvoucherseries', 'oxmanufacturers',
00139 'oxnews', 'oxselectlist', 'oxwrapping',
00140 'oxdeliveryset', 'oxdelivery', 'oxvendor', 'oxobject2category');
00141
00147 private static $_instance = null;
00148
00154 private $_oStart = null;
00155
00156
00162 protected $_oActShop = null;
00163
00171 protected $_oActView = null;
00172
00178 protected $_aGlobalParams = array();
00179
00185 protected $_aConfigParams = array();
00186
00192 protected $_iLanguageId = null;
00193
00199 protected $_iShopId = null;
00200
00201
00207 protected $_sOutDir = 'out';
00208
00214 protected $_sImageDir = 'img';
00215
00221 protected $_sPictureDir = 'pictures';
00222
00228 protected $_sMasterPictureDir = 'master';
00229
00235 protected $_sTemplateDir = 'tpl';
00236
00242 protected $_sResourceDir = 'src';
00243
00249 protected $_blIsSsl = null;
00250
00256 protected $_aAbsDynImageDir = array();
00257
00263 protected $_oActCurrencyObject = null;
00264
00272 public function getConfigParam( $sName )
00273 {
00274 if ( isset( $this->$sName ) ) {
00275 return $this->$sName;
00276 } elseif ( isset ( $this->_aConfigParams[$sName] ) ) {
00277 return $this->_aConfigParams[$sName];
00278 }
00279 }
00280
00289 public function setConfigParam( $sName, $sValue )
00290 {
00291 if ( isset( $this->$sName ) ) {
00292 $this->$sName = $sValue;
00293 } else {
00294 $this->_aConfigParams[$sName] = $sValue;
00295 }
00296 }
00297
00303 public function init()
00304 {
00305 include getShopBasePath().'config.inc.php';
00306 include getShopBasePath().'core/oxconfk.php';
00307
00308
00309 $oFileUtils = oxUtilsFile::getInstance();
00310 $this->sShopDir = $oFileUtils->normalizeDir($this->sShopDir);
00311 $this->sCompileDir = $oFileUtils->normalizeDir($this->sCompileDir);
00312 $this->sShopURL = $oFileUtils->normalizeDir($this->sShopURL);
00313 $this->sSSLShopURL = $oFileUtils->normalizeDir($this->sSSLShopURL);
00314 $this->sAdminSSLURL = $oFileUtils->normalizeDir($this->sAdminSSLURL);
00315
00316
00317
00318 if( !$this->getConfigParam( 'sDefaultLang' ) )
00319 $this->setConfigParam( 'sDefaultLang', 0 );
00320
00321 $blLogChangesInAdmin = $this->getConfigParam( 'blLogChangesInAdmin' );
00322 if( !isset( $blLogChangesInAdmin ) )
00323 $this->setConfigParam( 'blLogChangesInAdmin', false );
00324
00325 $blCheckTemplates = $this->getConfigParam( 'blCheckTemplates' );
00326 if( !isset( $blCheckTemplates ) )
00327 $this->setConfigParam( 'blCheckTemplates', false );
00328
00329 $blAllowArticlesubclass = $this->getConfigParam( 'blAllowArticlesubclass' );
00330 if( !isset( $blAllowArticlesubclass ) )
00331 $this->setConfigParam( 'blAllowArticlesubclass', false );
00332
00333 $iAdminListSize = $this->getConfigParam( 'iAdminListSize' );
00334 if( !isset( $iAdminListSize ) )
00335 $this->setConfigParam( 'iAdminListSize', 9 );
00336
00337
00338 $iPicCount = $this->getConfigParam( 'iPicCount' );
00339 if( !isset( $iPicCount ) )
00340 $this->setConfigParam( 'iPicCount', 7 );
00341
00342 $iZoomPicCount = $this->getConfigParam( 'iZoomPicCount' );
00343 if( !isset( $iZoomPicCount ) )
00344 $this->setConfigParam( 'iZoomPicCount', 4 );
00345
00346
00347 $iMaxShopId = $this->getConfigParam( 'iMaxShopId' );
00348 if( !isset( $iMaxShopId ) )
00349 $this->setConfigParam( 'iMaxShopId', 64 );
00350
00351
00352 $this->setConfigParam( 'blTemplateCaching', false );
00353
00354
00355 global $ADODB_SESS_LIFE;
00356 $ADODB_SESS_LIFE = 1;
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 $iDBCacheLifeTime = $this->getConfigParam( 'iDBCacheLifeTime' );
00370 if( !isset( $iDBCacheLifeTime ) )
00371 $this->setConfigParam( 'iDBCacheLifeTime', 3600 );
00372
00373 $sCoreDir = $this->getConfigParam( 'sShopDir' );
00374 $this->setConfigParam( 'sCoreDir', $sCoreDir.'/core/' );
00375
00376 try {
00377
00378 $this->getSession()->start();
00379
00380 $sShopID = $this->getShopId();
00381
00382
00383 $this->_loadVarsFromDb( $sShopID );
00384
00385 } catch ( oxConnectionException $oEx ) {
00386 $oEx->debugOut();
00387 if ( defined( 'OXID_PHP_UNIT' ) ) {
00388 return false;
00389 } elseif ( 0 != $this->iDebug ) {
00390 oxUtils::getInstance()->showMessageAndExit( $oEx->getString() );
00391 } else {
00392 header( "HTTP/1.1 500 Internal Server Error");
00393 header( "Location: offline.html");
00394 header( "Connection: close");
00395 }
00396 } catch ( oxCookieException $oEx ) {
00397
00398 oxUtilsView::getInstance()->addErrorToDisplay( $oEx );
00399 oxUtils::getInstance()->redirect( $this->getShopHomeURL() .'cl=start', true, 302 );
00400 }
00401
00402
00403 $this->_oStart = new oxStart();
00404 $this->_oStart->appInit();
00405 }
00406
00412 public static function getInstance()
00413 {
00414
00415 if ( defined( 'OXID_PHP_UNIT' ) ) {
00416 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00417 return modConfig::$unitMOD;
00418 }
00419 }
00420
00421 if ( !self::$_instance instanceof oxConfig ) {
00422
00423
00424 self::$_instance = new oxConfig();
00425 self::$_instance->init();
00426 }
00427 return self::$_instance;
00428 }
00429
00438 protected function _loadVarsFromDb( $sShopID, $aOnlyVars = null )
00439 {
00440
00441 $sQ = "select oxvarname, oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopID'";
00442
00443 if ( $aOnlyVars !== null ) {
00444 $blSep = false;
00445 $sIn = '';
00446 foreach ( $aOnlyVars as $sField ) {
00447 if ( $blSep ) {
00448 $sIn .= ', ';
00449 }
00450 $sIn .= '"'.$sField.'"';
00451 $blSep = true;
00452 }
00453 $sQ .= ' and oxvarname in ( '.$sIn.' ) ';
00454 }
00455
00456 $oRs = oxDb::getDb()->execute( $sQ );
00457 if ( $oRs != false && $oRs->recordCount() > 0 ) {
00458 while ( !$oRs->EOF ) {
00459 $sVarName = $oRs->fields[0];
00460 $sVarType = $oRs->fields[1];
00461 $sVarVal = $oRs->fields[2];
00462
00463
00464 if ( ( $sVarName == 'sShopURL' || $sVarName == 'sSSLShopURL' ) &&
00465 ( !$sVarVal || $this->isAdmin() === true ) ) {
00466 $oRs->moveNext();
00467 continue;
00468 }
00469
00470 switch ( $sVarType ) {
00471 case 'arr':
00472 case 'aarr':
00473 $this->setConfigParam( $sVarName, unserialize( $sVarVal ) );
00474 break;
00475 case 'bool':
00476 $this->setConfigParam( $sVarName, ( $sVarVal == 'true' || $sVarVal == '1' ) );
00477 break;
00478 default:
00479 $this->setConfigParam( $sVarName, $sVarVal );
00480 break;
00481 }
00482
00483 $oRs->moveNext();
00484 }
00485 }
00486
00487 }
00488
00494 public function pageClose()
00495 {
00496 return $this->_oStart->pageClose();
00497 }
00498
00512 public static function getParameter( $sName, $blRaw = false )
00513 {
00514 if ( defined( 'OXID_PHP_UNIT' ) ) {
00515 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00516 try{
00517 return modConfig::getParameter( $sName, $blRaw );
00518 } catch( Exception $e ) {
00519
00520 }
00521 }
00522 }
00523
00524 $sValue = null;
00525 if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST[$sName] ) ) {
00526 $sValue = $_POST[$sName];
00527 } elseif ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'GET' && isset( $_GET[$sName] ) ) {
00528 $sValue = $_GET[$sName];
00529
00530 } elseif ( oxSession::hasVar( $sName ) ) {
00531 $sValue = oxSession::getVar( $sName );
00532
00533 } else {
00534 $sValue = null;
00535 }
00536
00537
00538 $blIsAdmin = oxConfig::getInstance()->isAdmin() && oxSession::getVar("blIsAdmin");
00539 if ( $sValue != null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00540 self::checkSpecialChars( $sValue, $blRaw );
00541 }
00542
00543 return $sValue;
00544 }
00545
00553 public function getUploadedFile($sParamName)
00554 {
00555 return $_FILES[$sParamName];
00556 }
00557
00566 public function setGlobalParameter( $sName, $sValue )
00567 {
00568 $this->_aGlobalParams[$sName] = $sValue;
00569 }
00570
00578 public function getGlobalParameter( $sName )
00579 {
00580 if ( isset( $this->_aGlobalParams[$sName] ) ) {
00581 return $this->_aGlobalParams[$sName];
00582 } else {
00583 return null;
00584 }
00585 }
00586
00596 public static function checkSpecialChars( & $sValue, $aRaw = null )
00597 {
00598 if ( is_object( $sValue ) ) {
00599 return $sValue;
00600 }
00601
00602 if ( is_array( $sValue ) ) {
00603 $newValue = array();
00604 foreach ( $sValue as $sKey => $sVal ) {
00605 $sValidKey = $sKey;
00606 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00607 self::checkSpecialChars( $sValidKey );
00608 self::checkSpecialChars( $sVal );
00609 if ($sValidKey != $sKey) {
00610 unset ($sValue[$sKey]);
00611 }
00612 }
00613 $newValue[$sValidKey] = $sVal;
00614 }
00615 $sValue = $newValue;
00616 } else {
00617 $sValue = str_replace( array( '&', '<', '>', '"', "'", chr(0), '\\' ),
00618 array( '&', '<', '>', '"', ''', '', '\' ),
00619 $sValue );
00620 }
00621 return $sValue;
00622 }
00623
00629 public function getShopId()
00630 {
00631 if ( $this->_iShopId !== null )
00632 return $this->_iShopId;
00633
00634 $this->_iShopId = $this->getBaseShopId();
00635
00636
00637 oxSession::setVar( 'actshop', $this->_iShopId );
00638 return $this->_iShopId;
00639 }
00640
00641
00649 public function setShopId( $sShopId )
00650 {
00651 oxSession::setVar( 'actshop', $sShopId );
00652 $this->_iShopId = $sShopId;
00653 }
00654
00655
00661 public function isSsl()
00662 {
00663 if ( is_null( $this->_blIsSsl ) ) {
00664
00665 $myUtilsServer = oxUtilsServer::getInstance();
00666 $aServerVars = $myUtilsServer->getServerVar();
00667 $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00668
00669 $this->_blIsSsl = ( isset( $aHttpsServerVar ) && ( $this->getConfigParam( 'sSSLShopURL' ) || $this->getConfigParam( 'sMallSSLShopURL' ) ) &&
00670 ( $aHttpsServerVar === 'on' || $aHttpsServerVar == '1' ) );
00671
00672
00673 if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00674 ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00675 strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00676 $this->_blIsSsl = true;
00677 }
00678 }
00679
00680 return $this->_blIsSsl;
00681 }
00682
00690 public function isCurrentUrl( $sURL )
00691 {
00692 if ( !$sURL ) {
00693 return false;
00694 }
00695
00696 $oUtilsServer = oxUtilsServer::getInstance();
00697 $sHost = $oUtilsServer->getServerVar( 'HTTP_HOST' );
00698 $sScriptName = $oUtilsServer->getServerVar( 'SCRIPT_NAME' );
00699
00700 $sCurrentHost = preg_replace( '/\/\w*\.php.*/', '', $sHost . $sScriptName );
00701
00702
00703 $sCurrentHost = str_replace( '/', '', $sCurrentHost );
00704 $sURL = str_replace( '/', '', $sURL );
00705
00706
00707 if ( getStr()->strpos( $sURL, $sCurrentHost ) !== false ) {
00708 return true;
00709 }
00710
00711 return false;
00712 }
00713
00722 public function getShopUrl( $iLang = null, $blAdmin = null )
00723 {
00724 $blAdmin = isset( $blAdmin ) ? $blAdmin : $this->isAdmin();
00725 if ( $blAdmin ) {
00726 return $this->getConfigParam( 'sShopURL' );
00727 }
00728
00729
00730 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00731 $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00732 if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) && !empty( $aLanguageURLs[$iLang] ) ) {
00733 $aLanguageURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageURLs[$iLang] );
00734 return $aLanguageURLs[$iLang];
00735 }
00736
00737
00738 $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00739 if ( $sMallShopURL ) {
00740 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00741 return $sMallShopURL;
00742 }
00743
00744 return $this->getConfigParam( 'sShopURL' );
00745 }
00746
00754 public function getSslShopUrl( $iLang = null )
00755 {
00756
00757 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00758 $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
00759 if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) && !empty( $aLanguageSSLURLs[$iLang] ) ) {
00760 $aLanguageSSLURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageSSLURLs[$iLang] );
00761 return $aLanguageSSLURLs[$iLang];
00762 }
00763
00764
00765 if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
00766 $sMallSSLShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallSSLShopURL );
00767 return $sMallSSLShopURL;
00768 }
00769
00770 if ( ( $sMallShopURL = $this->getConfigParam( 'sMallShopURL' ) ) ) {
00771 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00772 return $sMallShopURL;
00773 }
00774
00775
00776 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00777 return $sSSLShopURL;
00778 }
00779
00780 return $this->getShopUrl( $iLang );
00781 }
00782
00788 public function getCoreUtilsUrl()
00789 {
00790 return $this->getCurrentShopUrl().'core/utils/';
00791 }
00792
00798 public function getCurrentShopUrl()
00799 {
00800 if ( $this->isSsl() ) {
00801 return $this->getSslShopUrl();
00802 }
00803 return $this->getShopUrl();
00804 }
00805
00813 public function getShopCurrentUrl( $iLang = null )
00814 {
00815 if ( $this->isSsl() ) {
00816 $sURL = $this->getSSLShopURL( $iLang );
00817 } else {
00818 $sURL = $this->getShopURL( $iLang );
00819 }
00820
00821 return oxUtilsUrl::getInstance()->processUrl( $sURL.'index.php', false );
00822 }
00823
00832 public function getShopHomeUrl( $iLang = null, $blAdmin = null )
00833 {
00834 return oxUtilsUrl::getInstance()->processUrl($this->getShopUrl( $iLang, $blAdmin).'index.php', false );
00835 }
00836
00842 public function getShopSecureHomeUrl()
00843 {
00844 return oxUtilsUrl::getInstance()->processUrl( $this->getSslShopUrl().'index.php', false );
00845 }
00846
00852 public function getShopCurrency()
00853 {
00854 return (int) oxConfig::getParameter( 'currency' );
00855 }
00856
00862 public function getActShopCurrencyObject()
00863 {
00864
00865
00866 if ( !defined( 'OXID_PHP_UNIT' ) ) {
00867 if (!is_null($this->_oActCurrencyObject)) {
00868 return $this->_oActCurrencyObject;
00869 }
00870 }
00871
00872 $iCur = oxConfig::getParameter( 'cur' );
00873 if ( !isset( $iCur ) ) {
00874 $iCur = $this->getShopCurrency();
00875 }
00876
00877 $aCurrencies = $this->getCurrencyArray();
00878 if ( !isset( $aCurrencies[$iCur] ) ) {
00879 return $this->_oActCurrencyObject = reset( $aCurrencies );
00880 }
00881
00882 return $this->_oActCurrencyObject = $aCurrencies[$iCur];
00883 }
00884
00892 public function setActShopCurrency( $iCur )
00893 {
00894 $aCurrencies = $this->getCurrencyArray();
00895 if ( isset( $aCurrencies[$iCur] ) ) {
00896 oxSession::setVar( 'currency', $iCur );
00897 $this->_oActCurrencyObject = null;
00898 }
00899 }
00900
00901
00911 public function getNoSslImageDir( $blAdmin = false )
00912 {
00913 return $this->getImageUrl( $blAdmin, false );
00914 }
00915
00923 public function getAbsAdminImageDir()
00924 {
00925 return $this->getImageDir( true );
00926
00927 }
00928
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
01003 public function getOutDir( $blAbsolute = true)
01004 {
01005 if ($blAbsolute) {
01006 return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01007 } else {
01008 return $this->_sOutDir.'/';
01009 }
01010 }
01011
01021 public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01022 {
01023 $blSSL = is_null($blSSL)?$this->isSsl():$blSSL;
01024 $blAdmin = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01025
01026 if ( $blSSL ) {
01027 $sUrl = ($blNativeImg && !$blAdmin )?$this->getSslShopUrl():$this->getConfigParam( 'sSSLShopURL');
01028 } else {
01029 $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01030 }
01031
01032 return $sUrl.$this->_sOutDir.'/';
01033 }
01034
01049 public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true, $blIgnoreCust = false )
01050 {
01051 if ( is_null($sTheme) ) {
01052 $sTheme = $this->getConfigParam( 'sTheme' );
01053 }
01054
01055 if ( $blAdmin ) {
01056 $sTheme = 'admin';
01057 }
01058
01059 $sBase = $this->getOutDir( $blAbsolute );
01060 $sAbsBase = $this->getOutDir();
01061
01062 $oLang = oxLang::getInstance();
01063
01064 if ( is_null($iLang) ) {
01065 $iLang = $oLang->getEditLanguage();
01066 }
01067
01068 $sLang = $oLang->getLanguageAbbr( $iLang );
01069
01070 if ( is_null($iShop) ) {
01071 $iShop = $this->getShopId();
01072 }
01073
01074
01075 $sPath = "$sTheme/$iShop/$sLang/$sDir/$sFile";
01076 $sCacheKey = $sPath . "_{$blIgnoreCust}{$blAbsolute}";
01077
01078 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01079 return $sReturn;
01080 }
01081
01082 $sReturn = false;
01083
01084
01085 $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
01086 if ( !$blAdmin && !$blIgnoreCust && $sCustomTheme && $sCustomTheme != $sTheme) {
01087 $sReturn = $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sCustomTheme, $blAbsolute );
01088 }
01089
01090
01091 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01092 $sReturn = $sBase . $sPath;
01093 }
01094
01095
01096 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01097 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01098 $sReturn = $sBase . $sPath;
01099 }
01100
01101
01102
01103 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01104 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01105 $sReturn = $sBase . $sPath;
01106 }
01107
01108
01109 $sPath = "$sTheme/$sDir/$sFile";
01110 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01111 $sReturn = $sBase . $sPath;
01112 }
01113
01114
01115 $sPath = "$sLang/$sDir/$sFile";
01116 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01117 $sReturn = $sBase . $sPath;
01118 }
01119
01120
01121 $sPath = "$sDir/$sFile";
01122 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01123 $sReturn = $sBase . $sPath;
01124 }
01125
01126 if ( !$sReturn ) {
01127
01128 }
01129
01130
01131 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01132
01133 return $sReturn;
01134 }
01135
01150 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01151 {
01152 $sUrl = str_replace(
01153 $this->getOutDir(),
01154 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01155 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01156 );
01157 return $sUrl;
01158 }
01159
01168 public function getImagePath( $sFile, $blAdmin = false )
01169 {
01170 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01171 }
01172
01182 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01183 {
01184 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01185 return $this->getUrl( null, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01186 }
01187
01195 public function getImageDir( $blAdmin = false )
01196 {
01197 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01198 }
01199
01208 public function getPicturePath($sFile, $blAdmin = false )
01209 {
01210 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01211 }
01212
01220 public function getMasterPictureDir( $blAdmin = false )
01221 {
01222 return $this->getDir( null, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01223 }
01224
01233 public function getMasterPicturePath( $sFile, $blAdmin = false )
01234 {
01235 return $this->getDir( $sFile, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01236 }
01237
01249 public function getPictureUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null )
01250 {
01251 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01252
01253 if ( $this->isSsl() ) {
01254 $sAltUrl = str_replace( 'http://', 'https://', $sAltUrl );
01255 }
01256
01257 if ( !is_null( $sFile ) ) {
01258 $sAltUrl .= $sFile;
01259 }
01260
01261 return $sAltUrl;
01262 }
01263
01264 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01265
01266 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01267 if ( $sFile && $this->getConfigParam( 'blFormerTplSupport' ) && !$blAdmin ) {
01268 $sUrl = str_replace( $this->getPictureUrl( null, $blAdmin, $blSSL, $iLang, $iShopId ), '', $sUrl );
01269 }
01270
01271
01272 if ( !$sUrl ) {
01273 $sUrl = $this->getUrl( "0/nopic.jpg", $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01274 }
01275 return $sUrl;
01276 }
01277
01285 public function getPictureDir( $blAdmin )
01286 {
01287 return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01288 }
01289
01298 public function getTemplatePath( $sFile, $blAdmin )
01299 {
01300 return $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01301 }
01302
01310 public function getTemplateDir( $blAdmin = false )
01311 {
01312 return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01313 }
01314
01325 public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01326 {
01327 return $this->getUrl( $sFile, $this->_sTemplateDir, $blAdmin, $blSSL, false, $iLang );
01328 }
01329
01337 public function getTemplateBase( $blAdmin = false )
01338 {
01339
01340 return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01341 }
01342
01351 public function getResourcePath($sFile, $blAdmin = false )
01352 {
01353 return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01354 }
01355
01366 public function getResourceUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null )
01367 {
01368 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01369 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, $blNativeImg, $iLang );
01370 }
01371
01379 public function getResourceDir( $blAdmin )
01380 {
01381 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01382 }
01383
01393 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01394 {
01395 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01396 }
01397
01407 public function getStdLanguagePath( $sFile, $blAdmin, $iLang = null )
01408 {
01409 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang, null, $this->getConfigParam( "sTheme" ), true, true );
01410 }
01411
01419 public function getLanguageDir( $blAdmin )
01420 {
01421 return $this->getDir( null, null, $blAdmin );
01422 }
01423
01431 public function getAbsImageDir()
01432 {
01433 return $this->getImageDir();
01434 }
01435
01446 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01447 {
01448 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491 }
01492
01502 public function getAbsDynImageDir( $sOverrideShopId = null )
01503 {
01504 return $this->getPictureDir(false);
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 }
01520
01531 public function getTemplateFile( $sTemplate, $blAdmin = false )
01532 {
01533 return $this->getTemplatePath( $sTemplate, $blAdmin );
01534 }
01535
01545 public function getBaseTemplateDir( $blAdmin = false )
01546 {
01547 return $this->getResourceUrl( null, $blAdmin );
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559 }
01560
01570 public function getBaseTplDir( $blAdmin = false )
01571 {
01572
01573 return $this->getResourceUrl( null, $blAdmin);
01574 }
01575
01583 public function getCurrencyArray( $iCurrency = null )
01584 {
01585 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01586 if ( !is_array( $aConfCurrencies ) ) {
01587 return array();
01588 }
01589
01590 if ( defined( 'OXID_PHP_UNIT' ) ) {
01591 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01592 try{
01593 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01594 if ( isset( $aAltCurrencies ) ) {
01595 $aConfCurrencies = $aAltCurrencies;
01596 }
01597 } catch( Exception $e ) {
01598
01599 }
01600 }
01601 }
01602
01603
01604 $aCurrencies = array();
01605 reset( $aConfCurrencies );
01606 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01607 if ( $val ) {
01608 $oCur = new oxStdClass();
01609 $oCur->id = $key;
01610 $sCur = explode( '@', $val);
01611 $oCur->name = trim( $sCur[0] );
01612 $oCur->rate = trim( $sCur[1] );
01613 $oCur->dec = trim( $sCur[2] );
01614 $oCur->thousand = trim( $sCur[3] );
01615 $oCur->sign = trim( $sCur[4] );
01616 $oCur->decimal = trim( $sCur[5] );
01617
01618
01619 if ( isset( $sCur[6] ) ) {
01620 $oCur->side = trim($sCur[6]);
01621 }
01622
01623 if ( isset( $iCurrency) && $key == $iCurrency ) {
01624 $oCur->selected = 1;
01625 } else {
01626 $oCur->selected = 0;
01627 }
01628 $aCurrencies[$key]= $oCur;
01629 }
01630
01631
01632 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01633 break;
01634 }
01635 }
01636 return $aCurrencies;
01637 }
01638
01646 public function getCurrencyObject( $sName )
01647 {
01648 $aSearch = $this->getCurrencyArray();
01649 foreach ( $aSearch as $oCur ) {
01650 if ( $oCur->name == $sName ) {
01651 return $oCur;
01652 }
01653 }
01654 }
01655
01661 public function isDemoShop()
01662 {
01663 return $this->getConfigParam('blDemoShop');
01664 }
01665
01671 public function getEdition()
01672 {
01673 return "CE";
01674
01675
01676 }
01677
01683 public function getFullEdition()
01684 {
01685 $sEdition = $this->getEdition();
01686
01687 if ($sEdition == "CE") {
01688 return "Community Edition";
01689 }
01690
01691
01692
01693 return $sEdition;
01694 }
01695
01701 public function getVersion()
01702 {
01703 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01704 return $sVersion;
01705 }
01706
01712 public function getRevision()
01713 {
01714 try {
01715 $sFileName = getShopBasePath() . "/pkg.rev";
01716 $iRev = (int) trim(@file_get_contents($sFileName));
01717 } catch (Exception $e) {
01718 return false;
01719 }
01720
01721 if (!$iRev) {
01722 return false;
01723 }
01724
01725 return $iRev;
01726 }
01727
01728
01734 public function isMall()
01735 {
01736
01737 return false;
01738 }
01739
01749 public function detectVersion()
01750 {
01751 }
01752
01753
01754
01766 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01767 {
01768 switch ( $sVarType ) {
01769 case 'arr':
01770 case 'aarr':
01771 if (is_array($sVarVal)) {
01772 $sValue = serialize( $sVarVal );
01773 } else {
01774
01775 $sValue = $sVarVal ;
01776 $sVarVal = unserialize( $sVarVal );
01777 }
01778 break;
01779 case 'bool':
01780
01781 $sVarVal = (( $sVarVal == 'true' || $sVarVal) && $sVarVal && strcasecmp($sVarVal, "false"));
01782
01783 $sValue = $sVarVal?"1":"";
01784 break;
01785 default:
01786 $sValue = $sVarVal;
01787 break;
01788 }
01789
01790 if ( !$sShopId ) {
01791 $sShopId = $this->getShopId();
01792 }
01793
01794
01795 if ($sShopId == $this->getShopId()) {
01796 $this->setConfigParam( $sVarName, $sVarVal );
01797 }
01798
01799 $oDb = oxDb::getDb();
01800 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01801 $oDb->execute( $sQ );
01802
01803 $sNewOXIDdQuoted = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
01804 $sShopIdQuoted = $oDb->quote($sShopId);
01805 $sVarNameQuoted = $oDb->quote($sVarName);
01806 $sVarTypeQuoted = $oDb->quote($sVarType);
01807 $sVarValueQuoted = $oDb->quote($sValue);
01808 $sConfigKeyQuoted = $oDb->quote($this->getConfigParam('sConfigKey'));
01809
01810 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01811 values($sNewOXIDdQuoted, $sShopIdQuoted, $sVarNameQuoted, $sVarTypeQuoted, ENCODE( $sVarValueQuoted, $sConfigKeyQuoted))";
01812
01813 $oDb->execute( $sQ );
01814 }
01815
01824 public function getShopConfVar( $sVarName, $sShopId = null )
01825 {
01826 if ( !$sShopId ) {
01827 $sShopId = $this->getShopId();
01828 }
01829
01830 $oDb = oxDb::getDb(true);
01831 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = ".$oDb->quote($sVarName);
01832 $oRs = $oDb->Execute( $sQ );
01833
01834 $sValue = null;
01835 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01836 $sVarType = $oRs->fields['oxvartype'];
01837 $sVarVal = $oRs->fields['oxvarvalue'];
01838 switch ( $sVarType ) {
01839 case 'arr':
01840 case 'aarr':
01841 $sValue = unserialize( $sVarVal );
01842 break;
01843 case 'bool':
01844 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01845 break;
01846 default:
01847 $sValue = $sVarVal;
01848 break;
01849 }
01850 }
01851 return $sValue;
01852 }
01853
01859 public function isProductiveMode()
01860 {
01861 $blProductive = false;
01862
01863 $blProductive = $this->getConfigParam( 'blProductive' );
01864 if ( !isset( $blProductive ) ) {
01865 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01866 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01867 $this->setConfigParam( 'blProductive', $blProductive );
01868 }
01869
01870 return $blProductive;
01871 }
01872
01873
01874
01880 public function getBaseShopId()
01881 {
01882
01883 return 'oxbaseshop';
01884 }
01885
01891 public function getActiveShop()
01892 {
01893 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01894 $this->_oActShop->getLanguage() == oxLang::getInstance()->getBaseLanguage() ) {
01895 return $this->_oActShop;
01896 }
01897
01898 $this->_oActShop = oxNew( 'oxshop' );
01899 $this->_oActShop->load( $this->getShopId() );
01900 return $this->_oActShop;
01901 }
01902
01908 public function getActiveView()
01909 {
01910 if ( $this->_oActView != null ) {
01911 return $this->_oActView;
01912 }
01913
01914 $this->_oActView = oxNew( 'oxubase' );
01915 return $this->_oActView;
01916 }
01917
01925 public function setActiveView( $oView )
01926 {
01927 $this->_oActView = $oView;
01928 }
01929
01935 public function isUtf()
01936 {
01937 return ( bool ) $this->getConfigParam( 'iUtfMode' );
01938 }
01939
01945 public function getLogsDir()
01946 {
01947 return $this->getConfigParam( 'sShopDir' ).'log/';
01948 }
01949 }