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 $sLang = '-';
01063
01064 if ( $iLang !== false ) {
01065 $oLang = oxLang::getInstance();
01066
01067 if ( is_null( $iLang ) ) {
01068 $iLang = $oLang->getEditLanguage();
01069 }
01070
01071 $sLang = $oLang->getLanguageAbbr( $iLang );
01072 }
01073
01074 if ( is_null($iShop) ) {
01075 $iShop = $this->getShopId();
01076 }
01077
01078
01079 $sPath = "{$sTheme}/{$iShop}/{$sLang}/{$sDir}/{$sFile}";
01080 $sCacheKey = $sPath . "_{$blIgnoreCust}{$blAbsolute}";
01081
01082 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01083 return $sReturn;
01084 }
01085
01086 $sReturn = false;
01087
01088
01089 $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
01090 if ( !$blAdmin && !$blIgnoreCust && $sCustomTheme && $sCustomTheme != $sTheme) {
01091 $sReturn = $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sCustomTheme, $blAbsolute );
01092 }
01093
01094
01095 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01096 $sReturn = $sBase . $sPath;
01097 }
01098
01099
01100 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01101 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01102 $sReturn = $sBase . $sPath;
01103 }
01104
01105
01106
01107 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01108 if ( !$sReturn && $iLang !== false && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01109 $sReturn = $sBase . $sPath;
01110 }
01111
01112
01113 $sPath = "$sTheme/$sDir/$sFile";
01114 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01115 $sReturn = $sBase . $sPath;
01116 }
01117
01118
01119 $sPath = "$sLang/$sDir/$sFile";
01120 if ( !$sReturn && $iLang !== false && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01121 $sReturn = $sBase . $sPath;
01122 }
01123
01124
01125 $sPath = "$sDir/$sFile";
01126 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01127 $sReturn = $sBase . $sPath;
01128 }
01129
01130 if ( !$sReturn ) {
01131
01132 }
01133
01134
01135 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01136
01137 return $sReturn;
01138 }
01139
01154 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01155 {
01156 $sUrl = str_replace(
01157 $this->getOutDir(),
01158 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01159 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01160 );
01161 return $sUrl;
01162 }
01163
01172 public function getImagePath( $sFile, $blAdmin = false )
01173 {
01174 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01175 }
01176
01186 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01187 {
01188 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01189 return $this->getUrl( null, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01190 }
01191
01199 public function getImageDir( $blAdmin = false )
01200 {
01201 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01202 }
01203
01212 public function getPicturePath($sFile, $blAdmin = false )
01213 {
01214 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01215 }
01216
01224 public function getMasterPictureDir( $blAdmin = false )
01225 {
01226 return $this->getDir( null, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01227 }
01228
01237 public function getMasterPicturePath( $sFile, $blAdmin = false )
01238 {
01239 return $this->getDir( $sFile, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01240 }
01241
01253 public function getPictureUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null )
01254 {
01255 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01256
01257 if ( $this->isSsl() ) {
01258 $sAltUrl = str_replace( 'http://', 'https://', $sAltUrl );
01259 }
01260
01261 if ( !is_null( $sFile ) ) {
01262 $sAltUrl .= $sFile;
01263 }
01264
01265 return $sAltUrl;
01266 }
01267
01268 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01269
01270 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01271 if ( $sFile && $this->getConfigParam( 'blFormerTplSupport' ) && !$blAdmin ) {
01272 $sUrl = str_replace( $this->getPictureUrl( null, $blAdmin, $blSSL, $iLang, $iShopId ), '', $sUrl );
01273 }
01274
01275
01276 if ( !$sUrl ) {
01277 $sUrl = $this->getUrl( "0/nopic.jpg", $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01278 }
01279 return $sUrl;
01280 }
01281
01289 public function getPictureDir( $blAdmin )
01290 {
01291 return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01292 }
01293
01302 public function getTemplatePath( $sFile, $blAdmin )
01303 {
01304 return $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01305 }
01306
01314 public function getTemplateDir( $blAdmin = false )
01315 {
01316 return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01317 }
01318
01329 public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01330 {
01331 return $this->getUrl( $sFile, $this->_sTemplateDir, $blAdmin, $blSSL, false, $iLang );
01332 }
01333
01341 public function getTemplateBase( $blAdmin = false )
01342 {
01343
01344 return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01345 }
01346
01355 public function getResourcePath($sFile, $blAdmin = false )
01356 {
01357 return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01358 }
01359
01370 public function getResourceUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null )
01371 {
01372 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01373 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, $blNativeImg, $iLang );
01374 }
01375
01383 public function getResourceDir( $blAdmin )
01384 {
01385 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01386 }
01387
01397 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01398 {
01399 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01400 }
01401
01411 public function getStdLanguagePath( $sFile, $blAdmin, $iLang = null )
01412 {
01413 $sDir = null;
01414 if ( $iLang !== false ) {
01415 $sDir = oxLang::getInstance()->getLanguageAbbr( $iLang );
01416 }
01417
01418 return $this->getDir( $sFile, $sDir, $blAdmin, $iLang, null, $this->getConfigParam( "sTheme" ), true, true );
01419 }
01420
01428 public function getLanguageDir( $blAdmin )
01429 {
01430 return $this->getDir( null, null, $blAdmin );
01431 }
01432
01440 public function getAbsImageDir()
01441 {
01442 return $this->getImageDir();
01443 }
01444
01455 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01456 {
01457 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
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
01493
01494
01495
01496
01497
01498
01499
01500 }
01501
01511 public function getAbsDynImageDir( $sOverrideShopId = null )
01512 {
01513 return $this->getPictureDir(false);
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528 }
01529
01540 public function getTemplateFile( $sTemplate, $blAdmin = false )
01541 {
01542 return $this->getTemplatePath( $sTemplate, $blAdmin );
01543 }
01544
01554 public function getBaseTemplateDir( $blAdmin = false )
01555 {
01556 return $this->getResourceUrl( null, $blAdmin );
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568 }
01569
01579 public function getBaseTplDir( $blAdmin = false )
01580 {
01581
01582 return $this->getResourceUrl( null, $blAdmin);
01583 }
01584
01592 public function getCurrencyArray( $iCurrency = null )
01593 {
01594 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01595 if ( !is_array( $aConfCurrencies ) ) {
01596 return array();
01597 }
01598
01599 if ( defined( 'OXID_PHP_UNIT' ) ) {
01600 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01601 try{
01602 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01603 if ( isset( $aAltCurrencies ) ) {
01604 $aConfCurrencies = $aAltCurrencies;
01605 }
01606 } catch( Exception $e ) {
01607
01608 }
01609 }
01610 }
01611
01612
01613 $aCurrencies = array();
01614 reset( $aConfCurrencies );
01615 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01616 if ( $val ) {
01617 $oCur = new oxStdClass();
01618 $oCur->id = $key;
01619 $sCur = explode( '@', $val);
01620 $oCur->name = trim( $sCur[0] );
01621 $oCur->rate = trim( $sCur[1] );
01622 $oCur->dec = trim( $sCur[2] );
01623 $oCur->thousand = trim( $sCur[3] );
01624 $oCur->sign = trim( $sCur[4] );
01625 $oCur->decimal = trim( $sCur[5] );
01626
01627
01628 if ( isset( $sCur[6] ) ) {
01629 $oCur->side = trim($sCur[6]);
01630 }
01631
01632 if ( isset( $iCurrency) && $key == $iCurrency ) {
01633 $oCur->selected = 1;
01634 } else {
01635 $oCur->selected = 0;
01636 }
01637 $aCurrencies[$key]= $oCur;
01638 }
01639
01640
01641 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01642 break;
01643 }
01644 }
01645 return $aCurrencies;
01646 }
01647
01655 public function getCurrencyObject( $sName )
01656 {
01657 $aSearch = $this->getCurrencyArray();
01658 foreach ( $aSearch as $oCur ) {
01659 if ( $oCur->name == $sName ) {
01660 return $oCur;
01661 }
01662 }
01663 }
01664
01670 public function isDemoShop()
01671 {
01672 return $this->getConfigParam('blDemoShop');
01673 }
01674
01680 public function getEdition()
01681 {
01682 return "CE";
01683
01684
01685 }
01686
01692 public function getFullEdition()
01693 {
01694 $sEdition = $this->getEdition();
01695
01696 if ($sEdition == "CE") {
01697 return "Community Edition";
01698 }
01699
01700
01701
01702 return $sEdition;
01703 }
01704
01710 public function getVersion()
01711 {
01712 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01713 return $sVersion;
01714 }
01715
01721 public function getRevision()
01722 {
01723 try {
01724 $sFileName = getShopBasePath() . "/pkg.rev";
01725 $iRev = (int) trim(@file_get_contents($sFileName));
01726 } catch (Exception $e) {
01727 return false;
01728 }
01729
01730 if (!$iRev) {
01731 return false;
01732 }
01733
01734 return $iRev;
01735 }
01736
01737
01743 public function isMall()
01744 {
01745
01746 return false;
01747 }
01748
01758 public function detectVersion()
01759 {
01760 }
01761
01762
01763
01775 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01776 {
01777 switch ( $sVarType ) {
01778 case 'arr':
01779 case 'aarr':
01780 if (is_array($sVarVal)) {
01781 $sValue = serialize( $sVarVal );
01782 } else {
01783
01784 $sValue = $sVarVal ;
01785 $sVarVal = unserialize( $sVarVal );
01786 }
01787 break;
01788 case 'bool':
01789
01790 $sVarVal = (( $sVarVal == 'true' || $sVarVal) && $sVarVal && strcasecmp($sVarVal, "false"));
01791
01792 $sValue = $sVarVal?"1":"";
01793 break;
01794 default:
01795 $sValue = $sVarVal;
01796 break;
01797 }
01798
01799 if ( !$sShopId ) {
01800 $sShopId = $this->getShopId();
01801 }
01802
01803
01804 if ($sShopId == $this->getShopId()) {
01805 $this->setConfigParam( $sVarName, $sVarVal );
01806 }
01807
01808 $oDb = oxDb::getDb();
01809 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01810 $oDb->execute( $sQ );
01811
01812 $sNewOXIDdQuoted = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
01813 $sShopIdQuoted = $oDb->quote($sShopId);
01814 $sVarNameQuoted = $oDb->quote($sVarName);
01815 $sVarTypeQuoted = $oDb->quote($sVarType);
01816 $sVarValueQuoted = $oDb->quote($sValue);
01817 $sConfigKeyQuoted = $oDb->quote($this->getConfigParam('sConfigKey'));
01818
01819 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01820 values($sNewOXIDdQuoted, $sShopIdQuoted, $sVarNameQuoted, $sVarTypeQuoted, ENCODE( $sVarValueQuoted, $sConfigKeyQuoted))";
01821
01822 $oDb->execute( $sQ );
01823 }
01824
01833 public function getShopConfVar( $sVarName, $sShopId = null )
01834 {
01835 if ( !$sShopId ) {
01836 $sShopId = $this->getShopId();
01837 }
01838
01839 $oDb = oxDb::getDb(true);
01840 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = ".$oDb->quote($sVarName);
01841 $oRs = $oDb->Execute( $sQ );
01842
01843 $sValue = null;
01844 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01845 $sVarType = $oRs->fields['oxvartype'];
01846 $sVarVal = $oRs->fields['oxvarvalue'];
01847 switch ( $sVarType ) {
01848 case 'arr':
01849 case 'aarr':
01850 $sValue = unserialize( $sVarVal );
01851 break;
01852 case 'bool':
01853 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01854 break;
01855 default:
01856 $sValue = $sVarVal;
01857 break;
01858 }
01859 }
01860 return $sValue;
01861 }
01862
01868 public function isProductiveMode()
01869 {
01870 $blProductive = false;
01871
01872 $blProductive = $this->getConfigParam( 'blProductive' );
01873 if ( !isset( $blProductive ) ) {
01874 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01875 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01876 $this->setConfigParam( 'blProductive', $blProductive );
01877 }
01878
01879 return $blProductive;
01880 }
01881
01882
01883
01889 public function getBaseShopId()
01890 {
01891
01892 return 'oxbaseshop';
01893 }
01894
01900 public function getActiveShop()
01901 {
01902 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01903 $this->_oActShop->getLanguage() == oxLang::getInstance()->getBaseLanguage() ) {
01904 return $this->_oActShop;
01905 }
01906
01907 $this->_oActShop = oxNew( 'oxshop' );
01908 $this->_oActShop->load( $this->getShopId() );
01909 return $this->_oActShop;
01910 }
01911
01917 public function getActiveView()
01918 {
01919 if ( $this->_oActView != null ) {
01920 return $this->_oActView;
01921 }
01922
01923 $this->_oActView = oxNew( 'oxubase' );
01924 return $this->_oActView;
01925 }
01926
01934 public function setActiveView( $oView )
01935 {
01936 $this->_oActView = $oView;
01937 }
01938
01944 public function isUtf()
01945 {
01946 return ( bool ) $this->getConfigParam( 'iUtfMode' );
01947 }
01948
01954 public function getLogsDir()
01955 {
01956 return $this->getConfigParam( 'sShopDir' ).'log/';
01957 }
01958 }