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
00386 } catch ( oxConnectionException $oEx ) {
00387 $oEx->debugOut();
00388 if ( defined( 'OXID_PHP_UNIT' ) ) {
00389 return false;
00390 } elseif ( 0 != $this->iDebug ) {
00391 oxUtils::getInstance()->showMessageAndExit( $oEx->getString() );
00392 } else {
00393 header( "HTTP/1.1 500 Internal Server Error");
00394 header( "Location: offline.html");
00395 header( "Connection: close");
00396 }
00397 } catch ( oxCookieException $oEx ) {
00398
00399 oxUtilsView::getInstance()->addErrorToDisplay( $oEx );
00400 oxUtils::getInstance()->redirect( $this->getShopHomeURL() .'cl=start', true, 302 );
00401 }
00402
00403
00404 $this->_oStart = new oxStart();
00405 $this->_oStart->appInit();
00406 }
00407
00413 public static function getInstance()
00414 {
00415
00416 if ( defined( 'OXID_PHP_UNIT' ) ) {
00417 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00418 return modConfig::$unitMOD;
00419 }
00420 }
00421
00422 if ( !self::$_instance instanceof oxConfig ) {
00423
00424
00425 self::$_instance = new oxConfig();
00426 self::$_instance->init();
00427 }
00428 return self::$_instance;
00429 }
00430
00439 protected function _loadVarsFromDb( $sShopID, $aOnlyVars = null )
00440 {
00441
00442 $sQ = "select oxvarname, oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopID'";
00443
00444 if ( $aOnlyVars !== null ) {
00445 $blSep = false;
00446 $sIn = '';
00447 foreach ( $aOnlyVars as $sField ) {
00448 if ( $blSep ) {
00449 $sIn .= ', ';
00450 }
00451 $sIn .= '"'.$sField.'"';
00452 $blSep = true;
00453 }
00454 $sQ .= ' and oxvarname in ( '.$sIn.' ) ';
00455 }
00456
00457 $oRs = oxDb::getDb()->execute( $sQ );
00458 if ( $oRs != false && $oRs->recordCount() > 0 ) {
00459 while ( !$oRs->EOF ) {
00460 $sVarName = $oRs->fields[0];
00461 $sVarType = $oRs->fields[1];
00462 $sVarVal = $oRs->fields[2];
00463
00464
00465 if ( ( $sVarName == 'sShopURL' || $sVarName == 'sSSLShopURL' ) &&
00466 ( !$sVarVal || $this->isAdmin() === true ) ) {
00467 $oRs->moveNext();
00468 continue;
00469 }
00470
00471 switch ( $sVarType ) {
00472 case 'arr':
00473 case 'aarr':
00474 $this->setConfigParam( $sVarName, unserialize( $sVarVal ) );
00475 break;
00476 case 'bool':
00477 $this->setConfigParam( $sVarName, ( $sVarVal == 'true' || $sVarVal == '1' ) );
00478 break;
00479 default:
00480 $this->setConfigParam( $sVarName, $sVarVal );
00481 break;
00482 }
00483
00484 $oRs->moveNext();
00485 }
00486 }
00487
00488 }
00489
00495 public function pageClose()
00496 {
00497 return $this->_oStart->pageClose();
00498 }
00499
00513 public static function getParameter( $sName, $blRaw = false )
00514 {
00515 if ( defined( 'OXID_PHP_UNIT' ) ) {
00516 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00517 try{
00518 return modConfig::getParameter( $sName, $blRaw );
00519 } catch( Exception $e ) {
00520
00521 }
00522 }
00523 }
00524
00525 $sValue = null;
00526 if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST[$sName] ) ) {
00527 $sValue = $_POST[$sName];
00528 } elseif ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'GET' && isset( $_GET[$sName] ) ) {
00529 $sValue = $_GET[$sName];
00530
00531 } elseif ( oxSession::hasVar( $sName ) ) {
00532 $sValue = oxSession::getVar( $sName );
00533
00534 } else {
00535 $sValue = null;
00536 }
00537
00538
00539 $blIsAdmin = oxConfig::getInstance()->isAdmin() && oxSession::getVar("blIsAdmin");
00540 if ( $sValue != null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00541 self::checkSpecialChars( $sValue, $blRaw );
00542 }
00543
00544 return $sValue;
00545 }
00546
00554 public function getUploadedFile($sParamName)
00555 {
00556 return $_FILES[$sParamName];
00557 }
00558
00567 public function setGlobalParameter( $sName, $sValue )
00568 {
00569 $this->_aGlobalParams[$sName] = $sValue;
00570 }
00571
00579 public function getGlobalParameter( $sName )
00580 {
00581 if ( isset( $this->_aGlobalParams[$sName] ) ) {
00582 return $this->_aGlobalParams[$sName];
00583 } else {
00584 return null;
00585 }
00586 }
00587
00597 public static function checkSpecialChars( & $sValue, $aRaw = null )
00598 {
00599 if ( is_object( $sValue ) ) {
00600 return $sValue;
00601 }
00602
00603 if ( is_array( $sValue ) ) {
00604 $newValue = array();
00605 foreach ( $sValue as $sKey => $sVal ) {
00606 $sValidKey = $sKey;
00607 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00608 self::checkSpecialChars( $sValidKey );
00609 self::checkSpecialChars( $sVal );
00610 if ($sValidKey != $sKey) {
00611 unset ($sValue[$sKey]);
00612 }
00613 }
00614 $newValue[$sValidKey] = $sVal;
00615 }
00616 $sValue = $newValue;
00617 } else {
00618 $sValue = str_replace( array( '&', '<', '>', '"', "'", chr(0), '\\' ),
00619 array( '&', '<', '>', '"', ''', '', '\' ),
00620 $sValue );
00621 }
00622 return $sValue;
00623 }
00624
00630 public function getShopId()
00631 {
00632 if ( $this->_iShopId !== null )
00633 return $this->_iShopId;
00634
00635 $this->_iShopId = $this->getBaseShopId();
00636
00637
00638 oxSession::setVar( 'actshop', $this->_iShopId );
00639 return $this->_iShopId;
00640 }
00641
00642
00650 public function setShopId( $sShopId )
00651 {
00652 oxSession::setVar( 'actshop', $sShopId );
00653 $this->_iShopId = $sShopId;
00654 }
00655
00656
00662 public function isSsl()
00663 {
00664 if ( is_null( $this->_blIsSsl ) ) {
00665
00666 $myUtilsServer = oxUtilsServer::getInstance();
00667 $aServerVars = $myUtilsServer->getServerVar();
00668 $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00669
00670 $this->_blIsSsl = ( isset( $aHttpsServerVar ) && ( $this->getConfigParam( 'sSSLShopURL' ) || $this->getConfigParam( 'sMallSSLShopURL' ) ) &&
00671 ( $aHttpsServerVar === 'on' || $aHttpsServerVar == '1' ) );
00672
00673
00674 if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00675 ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00676 strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00677 $this->_blIsSsl = true;
00678 }
00679 }
00680
00681 return $this->_blIsSsl;
00682 }
00683
00691 public function isCurrentUrl( $sURL )
00692 {
00693 if ( !$sURL ) {
00694 return false;
00695 }
00696
00697 $oUtilsServer = oxUtilsServer::getInstance();
00698 $sHost = $oUtilsServer->getServerVar( 'HTTP_HOST' );
00699 $sScriptName = $oUtilsServer->getServerVar( 'SCRIPT_NAME' );
00700
00701 $sCurrentHost = preg_replace( '/\/\w*\.php.*/', '', $sHost . $sScriptName );
00702
00703
00704 $sCurrentHost = str_replace( '/', '', $sCurrentHost );
00705 $sURL = str_replace( '/', '', $sURL );
00706
00707
00708 if ( getStr()->strpos( $sURL, $sCurrentHost ) !== false ) {
00709 return true;
00710 }
00711
00712 return false;
00713 }
00714
00723 public function getShopUrl( $iLang = null, $blAdmin = null )
00724 {
00725 $blAdmin = isset( $blAdmin ) ? $blAdmin : $this->isAdmin();
00726 if ( $blAdmin ) {
00727 return $this->getConfigParam( 'sShopURL' );
00728 }
00729
00730
00731 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00732 $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00733 if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) && !empty( $aLanguageURLs[$iLang] ) ) {
00734 $aLanguageURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageURLs[$iLang] );
00735 return $aLanguageURLs[$iLang];
00736 }
00737
00738
00739 $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00740 if ( $sMallShopURL ) {
00741 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00742 return $sMallShopURL;
00743 }
00744
00745 return $this->getConfigParam( 'sShopURL' );
00746 }
00747
00755 public function getSslShopUrl( $iLang = null )
00756 {
00757
00758 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00759 $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
00760 if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) && !empty( $aLanguageSSLURLs[$iLang] ) ) {
00761 $aLanguageSSLURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageSSLURLs[$iLang] );
00762 return $aLanguageSSLURLs[$iLang];
00763 }
00764
00765
00766 if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
00767 $sMallSSLShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallSSLShopURL );
00768 return $sMallSSLShopURL;
00769 }
00770
00771 if ( ( $sMallShopURL = $this->getConfigParam( 'sMallShopURL' ) ) ) {
00772 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00773 return $sMallShopURL;
00774 }
00775
00776
00777 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00778 return $sSSLShopURL;
00779 }
00780
00781 return $this->getShopUrl( $iLang );
00782 }
00783
00789 public function getCoreUtilsUrl()
00790 {
00791 return $this->getCurrentShopUrl().'core/utils/';
00792 }
00793
00799 public function getCurrentShopUrl()
00800 {
00801 if ( $this->isSsl() ) {
00802 return $this->getSslShopUrl();
00803 }
00804 return $this->getShopUrl();
00805 }
00806
00814 public function getShopCurrentUrl( $iLang = null )
00815 {
00816 if ( $this->isSsl() ) {
00817 $sURL = $this->getSSLShopURL( $iLang );
00818 } else {
00819 $sURL = $this->getShopURL( $iLang );
00820 }
00821
00822 return oxUtilsUrl::getInstance()->processUrl( $sURL.'index.php', false );
00823 }
00824
00833 public function getShopHomeUrl( $iLang = null, $blAdmin = null )
00834 {
00835 return oxUtilsUrl::getInstance()->processUrl($this->getShopUrl( $iLang, $blAdmin).'index.php', false );
00836 }
00837
00843 public function getShopSecureHomeUrl()
00844 {
00845 return oxUtilsUrl::getInstance()->processUrl( $this->getSslShopUrl().'index.php', false );
00846 }
00847
00853 public function getShopCurrency()
00854 {
00855 return (int) oxConfig::getParameter( 'currency' );
00856 }
00857
00863 public function getActShopCurrencyObject()
00864 {
00865
00866
00867 if ( !defined( 'OXID_PHP_UNIT' ) ) {
00868 if (!is_null($this->_oActCurrencyObject)) {
00869 return $this->_oActCurrencyObject;
00870 }
00871 }
00872
00873 $iCur = oxConfig::getParameter( 'cur' );
00874 if ( !isset( $iCur ) ) {
00875 $iCur = $this->getShopCurrency();
00876 }
00877
00878 $aCurrencies = $this->getCurrencyArray();
00879 if ( !isset( $aCurrencies[$iCur] ) ) {
00880 return $this->_oActCurrencyObject = reset( $aCurrencies );
00881 }
00882
00883 return $this->_oActCurrencyObject = $aCurrencies[$iCur];
00884 }
00885
00893 public function setActShopCurrency( $iCur )
00894 {
00895 $aCurrencies = $this->getCurrencyArray();
00896 if ( isset( $aCurrencies[$iCur] ) ) {
00897 oxSession::setVar( 'currency', $iCur );
00898 $this->_oActCurrencyObject = null;
00899 }
00900 }
00901
00902
00912 public function getNoSslImageDir( $blAdmin = false )
00913 {
00914 return $this->getImageUrl( $blAdmin, false );
00915 }
00916
00924 public function getAbsAdminImageDir()
00925 {
00926 return $this->getImageDir( true );
00927
00928 }
00929
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
00996
01004 public function getOutDir( $blAbsolute = true)
01005 {
01006 if ($blAbsolute) {
01007 return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01008 } else {
01009 return $this->_sOutDir.'/';
01010 }
01011 }
01012
01022 public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01023 {
01024 $blSSL = is_null($blSSL)?$this->isSsl():$blSSL;
01025 $blAdmin = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01026
01027 if ( $blSSL ) {
01028 $sUrl = ($blNativeImg && !$blAdmin )?$this->getSslShopUrl():$this->getConfigParam( 'sSSLShopURL');
01029 } else {
01030 $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01031 }
01032
01033 return $sUrl.$this->_sOutDir.'/';
01034 }
01035
01050 public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true, $blIgnoreCust = false )
01051 {
01052 if ( is_null($sTheme) ) {
01053 $sTheme = $this->getConfigParam( 'sTheme' );
01054 }
01055
01056 if ( $blAdmin ) {
01057 $sTheme = 'admin';
01058 }
01059
01060 $sBase = $this->getOutDir( $blAbsolute );
01061 $sAbsBase = $this->getOutDir();
01062
01063 $sLang = '-';
01064
01065 if ( $iLang !== false ) {
01066 $oLang = oxLang::getInstance();
01067
01068 if ( is_null( $iLang ) ) {
01069 $iLang = $oLang->getEditLanguage();
01070 }
01071
01072 $sLang = $oLang->getLanguageAbbr( $iLang );
01073 }
01074
01075 if ( is_null($iShop) ) {
01076 $iShop = $this->getShopId();
01077 }
01078
01079
01080 $sPath = "{$sTheme}/{$iShop}/{$sLang}/{$sDir}/{$sFile}";
01081 $sCacheKey = $sPath . "_{$blIgnoreCust}{$blAbsolute}";
01082
01083 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01084 return $sReturn;
01085 }
01086
01087 $sReturn = false;
01088
01089
01090 $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
01091 if ( !$blAdmin && !$blIgnoreCust && $sCustomTheme && $sCustomTheme != $sTheme) {
01092 $sReturn = $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sCustomTheme, $blAbsolute );
01093 }
01094
01095
01096 if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01097 $sReturn = $sBase . $sPath;
01098 }
01099
01100
01101 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01102 if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01103 $sReturn = $sBase . $sPath;
01104 }
01105
01106
01107
01108 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01109 if ( !$sReturn && $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01110 $sReturn = $sBase . $sPath;
01111 }
01112
01113
01114 $sPath = "$sTheme/$sDir/$sFile";
01115 if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01116 $sReturn = $sBase . $sPath;
01117 }
01118
01119
01120 $sPath = "$sLang/$sDir/$sFile";
01121 if ( !$sReturn && $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01122 $sReturn = $sBase . $sPath;
01123 }
01124
01125
01126 $sPath = "$sDir/$sFile";
01127 if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01128 $sReturn = $sBase . $sPath;
01129 }
01130
01131 if ( !$sReturn ) {
01132
01133 }
01134
01135
01136 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01137
01138 return $sReturn;
01139 }
01140
01155 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01156 {
01157 $sUrl = str_replace(
01158 $this->getOutDir(),
01159 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01160 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01161 );
01162 return $sUrl;
01163 }
01164
01173 public function getImagePath( $sFile, $blAdmin = false )
01174 {
01175 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01176 }
01177
01187 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01188 {
01189 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01190 return $this->getUrl( null, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01191 }
01192
01200 public function getImageDir( $blAdmin = false )
01201 {
01202 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01203 }
01204
01213 public function getPicturePath($sFile, $blAdmin = false )
01214 {
01215 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01216 }
01217
01225 public function getMasterPictureDir( $blAdmin = false )
01226 {
01227 return $this->getDir( null, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01228 }
01229
01238 public function getMasterPicturePath( $sFile, $blAdmin = false )
01239 {
01240 return $this->getDir( $sFile, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01241 }
01242
01255 public function getPictureUrl( $sFile, $blAdmin = false, $blSSL = null, $iLang = null, $iShopId = null, $sDefPic = "0/nopic.jpg" )
01256 {
01257 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01258
01259 if ( $this->isSsl() && $blSSL && $sSslAltUrl = $this->getConfigParam( 'sSSLAltImageDir' ) ) {
01260 $sAltUrl = $sSslAltUrl;
01261 }
01262
01263 if ( !is_null( $sFile ) ) {
01264 $sAltUrl .= $sFile;
01265 }
01266
01267 return $sAltUrl;
01268 }
01269
01270 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01271
01272 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01273 if ( $sFile && $this->getConfigParam( 'blFormerTplSupport' ) && !$blAdmin ) {
01274 $sUrl = str_replace( $this->getPictureUrl( null, $blAdmin, $blSSL, $iLang, $iShopId ), '', $sUrl );
01275 }
01276
01277
01278 if ( !$sUrl ) {
01279 $sUrl = $this->getUrl( $sDefPic, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01280 }
01281 return $sUrl;
01282 }
01283
01296 public function getIconUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null, $sDefPic = "icon/nopic_ico.jpg" )
01297 {
01298 return $this->getPictureUrl( $sFile, $blAdmin, $blSSL, $iLang, $iShopId, $sDefPic );
01299 }
01300
01308 public function getPictureDir( $blAdmin )
01309 {
01310 return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01311 }
01312
01321 public function getTemplatePath( $sFile, $blAdmin )
01322 {
01323 return $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01324 }
01325
01333 public function getTemplateDir( $blAdmin = false )
01334 {
01335 return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01336 }
01337
01348 public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01349 {
01350 return $this->getUrl( $sFile, $this->_sTemplateDir, $blAdmin, $blSSL, false, $iLang );
01351 }
01352
01360 public function getTemplateBase( $blAdmin = false )
01361 {
01362
01363 return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01364 }
01365
01374 public function getResourcePath($sFile, $blAdmin = false )
01375 {
01376 return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01377 }
01378
01389 public function getResourceUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null )
01390 {
01391 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01392 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, $blNativeImg, $iLang );
01393 }
01394
01402 public function getResourceDir( $blAdmin )
01403 {
01404 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01405 }
01406
01416 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01417 {
01418 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01419 }
01420
01430 public function getStdLanguagePath( $sFile, $blAdmin, $iLang = null )
01431 {
01432 $sDir = null;
01433 if ( $iLang !== false ) {
01434 $sDir = oxLang::getInstance()->getLanguageAbbr( $iLang );
01435 }
01436
01437 return $this->getDir( $sFile, $sDir, $blAdmin, $iLang, null, $this->getConfigParam( "sTheme" ), true, true );
01438 }
01439
01447 public function getLanguageDir( $blAdmin )
01448 {
01449 return $this->getDir( null, null, $blAdmin );
01450 }
01451
01459 public function getAbsImageDir()
01460 {
01461 return $this->getImageDir();
01462 }
01463
01474 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01475 {
01476 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
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
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 }
01520
01530 public function getAbsDynImageDir( $sOverrideShopId = null )
01531 {
01532 return $this->getPictureDir(false);
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547 }
01548
01559 public function getTemplateFile( $sTemplate, $blAdmin = false )
01560 {
01561 return $this->getTemplatePath( $sTemplate, $blAdmin );
01562 }
01563
01573 public function getBaseTemplateDir( $blAdmin = false )
01574 {
01575 return $this->getResourceUrl( null, $blAdmin );
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587 }
01588
01598 public function getBaseTplDir( $blAdmin = false )
01599 {
01600
01601 return $this->getResourceUrl( null, $blAdmin);
01602 }
01603
01611 public function getCurrencyArray( $iCurrency = null )
01612 {
01613 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01614 if ( !is_array( $aConfCurrencies ) ) {
01615 return array();
01616 }
01617
01618 if ( defined( 'OXID_PHP_UNIT' ) ) {
01619 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01620 try{
01621 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01622 if ( isset( $aAltCurrencies ) ) {
01623 $aConfCurrencies = $aAltCurrencies;
01624 }
01625 } catch( Exception $e ) {
01626
01627 }
01628 }
01629 }
01630
01631
01632 $aCurrencies = array();
01633 reset( $aConfCurrencies );
01634 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01635 if ( $val ) {
01636 $oCur = new oxStdClass();
01637 $oCur->id = $key;
01638 $sCur = explode( '@', $val);
01639 $oCur->name = trim( $sCur[0] );
01640 $oCur->rate = trim( $sCur[1] );
01641 $oCur->dec = trim( $sCur[2] );
01642 $oCur->thousand = trim( $sCur[3] );
01643 $oCur->sign = trim( $sCur[4] );
01644 $oCur->decimal = trim( $sCur[5] );
01645
01646
01647 if ( isset( $sCur[6] ) ) {
01648 $oCur->side = trim($sCur[6]);
01649 }
01650
01651 if ( isset( $iCurrency) && $key == $iCurrency ) {
01652 $oCur->selected = 1;
01653 } else {
01654 $oCur->selected = 0;
01655 }
01656 $aCurrencies[$key]= $oCur;
01657 }
01658
01659
01660 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01661 break;
01662 }
01663 }
01664 return $aCurrencies;
01665 }
01666
01674 public function getCurrencyObject( $sName )
01675 {
01676 $aSearch = $this->getCurrencyArray();
01677 foreach ( $aSearch as $oCur ) {
01678 if ( $oCur->name == $sName ) {
01679 return $oCur;
01680 }
01681 }
01682 }
01683
01689 public function isDemoShop()
01690 {
01691 return $this->getConfigParam('blDemoShop');
01692 }
01693
01699 public function getEdition()
01700 {
01701 return "CE";
01702
01703
01704 }
01705
01711 public function getFullEdition()
01712 {
01713 $sEdition = $this->getEdition();
01714
01715 if ($sEdition == "CE") {
01716 return "Community Edition";
01717 }
01718
01719
01720
01721 return $sEdition;
01722 }
01723
01729 public function getVersion()
01730 {
01731 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01732 return $sVersion;
01733 }
01734
01740 public function getRevision()
01741 {
01742 try {
01743 $sFileName = getShopBasePath() . "/pkg.rev";
01744 $iRev = (int) trim(@file_get_contents($sFileName));
01745 } catch (Exception $e) {
01746 return false;
01747 }
01748
01749 if (!$iRev) {
01750 return false;
01751 }
01752
01753 return $iRev;
01754 }
01755
01756
01762 public function isMall()
01763 {
01764
01765 return false;
01766 }
01767
01777 public function detectVersion()
01778 {
01779 }
01780
01781
01782
01794 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01795 {
01796 switch ( $sVarType ) {
01797 case 'arr':
01798 case 'aarr':
01799 if (is_array($sVarVal)) {
01800 $sValue = serialize( $sVarVal );
01801 } else {
01802
01803 $sValue = $sVarVal ;
01804 $sVarVal = unserialize( $sVarVal );
01805 }
01806 break;
01807 case 'bool':
01808
01809 $sVarVal = (( $sVarVal == 'true' || $sVarVal) && $sVarVal && strcasecmp($sVarVal, "false"));
01810
01811 $sValue = $sVarVal?"1":"";
01812 break;
01813 default:
01814 $sValue = $sVarVal;
01815 break;
01816 }
01817
01818 if ( !$sShopId ) {
01819 $sShopId = $this->getShopId();
01820 }
01821
01822
01823 if ($sShopId == $this->getShopId()) {
01824 $this->setConfigParam( $sVarName, $sVarVal );
01825 }
01826
01827 $oDb = oxDb::getDb();
01828 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01829 $oDb->execute( $sQ );
01830
01831 $sNewOXIDdQuoted = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
01832 $sShopIdQuoted = $oDb->quote($sShopId);
01833 $sVarNameQuoted = $oDb->quote($sVarName);
01834 $sVarTypeQuoted = $oDb->quote($sVarType);
01835 $sVarValueQuoted = $oDb->quote($sValue);
01836 $sConfigKeyQuoted = $oDb->quote($this->getConfigParam('sConfigKey'));
01837
01838 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01839 values($sNewOXIDdQuoted, $sShopIdQuoted, $sVarNameQuoted, $sVarTypeQuoted, ENCODE( $sVarValueQuoted, $sConfigKeyQuoted))";
01840
01841 $oDb->execute( $sQ );
01842 }
01843
01852 public function getShopConfVar( $sVarName, $sShopId = null )
01853 {
01854 if ( !$sShopId ) {
01855 $sShopId = $this->getShopId();
01856 }
01857
01858 $oDb = oxDb::getDb(true);
01859 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = ".$oDb->quote($sVarName);
01860 $oRs = $oDb->Execute( $sQ );
01861
01862 $sValue = null;
01863 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01864 $sVarType = $oRs->fields['oxvartype'];
01865 $sVarVal = $oRs->fields['oxvarvalue'];
01866 switch ( $sVarType ) {
01867 case 'arr':
01868 case 'aarr':
01869 $sValue = unserialize( $sVarVal );
01870 break;
01871 case 'bool':
01872 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01873 break;
01874 default:
01875 $sValue = $sVarVal;
01876 break;
01877 }
01878 }
01879 return $sValue;
01880 }
01881
01887 public function isProductiveMode()
01888 {
01889 $blProductive = false;
01890
01891 $blProductive = $this->getConfigParam( 'blProductive' );
01892 if ( !isset( $blProductive ) ) {
01893 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01894 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01895 $this->setConfigParam( 'blProductive', $blProductive );
01896 }
01897
01898 return $blProductive;
01899 }
01900
01901
01902
01908 public function getBaseShopId()
01909 {
01910
01911 return 'oxbaseshop';
01912 }
01913
01919 public function getActiveShop()
01920 {
01921 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01922 $this->_oActShop->getLanguage() == oxLang::getInstance()->getBaseLanguage() ) {
01923 return $this->_oActShop;
01924 }
01925
01926 $this->_oActShop = oxNew( 'oxshop' );
01927 $this->_oActShop->load( $this->getShopId() );
01928 return $this->_oActShop;
01929 }
01930
01936 public function getActiveView()
01937 {
01938 if ( $this->_oActView != null ) {
01939 return $this->_oActView;
01940 }
01941
01942 $this->_oActView = oxNew( 'oxubase' );
01943 return $this->_oActView;
01944 }
01945
01953 public function setActiveView( $oView )
01954 {
01955 $this->_oActView = $oView;
01956 }
01957
01963 public function isUtf()
01964 {
01965 return ( bool ) $this->getConfigParam( 'iUtfMode' );
01966 }
01967
01973 public function getLogsDir()
01974 {
01975 return $this->getConfigParam( 'sShopDir' ).'log/';
01976 }
01977 }