00001 <?php
00002
00003 define( 'MAX_64BIT_INTEGER', '18446744073709551615' );
00004
00010 class oxConfig extends oxSuperCfg
00011 {
00012
00013
00014
00020 protected $dbHost = null;
00021
00027 protected $dbName = null;
00028
00034 protected $dbUser = null;
00035
00041 protected $dbPwd = null;
00042
00048 protected $dbType = null;
00049
00055 protected $sShopURL = null;
00056
00062 protected $sSSLShopURL = null;
00063
00069 protected $sAdminSSLURL = null;
00070
00076 protected $sShopDir = null;
00077
00083 protected $sCompileDir = null;
00084
00099 protected $iDebug = 0;
00100
00106 protected $sAdminEmail = null;
00107
00113 protected $blSessionUseCookies = null;
00114
00120 protected $blSessionEnforceCookies = null;
00121
00127
00128
00138 protected $blNativeImages = true;
00139
00145 protected $aMultiShopTables = array( 'oxarticles', 'oxdiscount', 'oxcategories', 'oxattribute',
00146 'oxlinks', 'oxvoucherseries',
00147 'oxnews', 'oxselectlist', 'oxwrapping',
00148 'oxdeliveryset', 'oxdelivery', 'oxvendor', 'oxobject2category');
00149
00155 private static $_instance = null;
00156
00162 private $_oStart = null;
00163
00164
00170 protected $_oActShop = null;
00171
00179 protected $_oActView = null;
00180
00186 protected $_aGlobalParams = array();
00187
00193 protected $_aConfigParams = array();
00194
00200 protected $_iLanguageId = null;
00201
00207 protected $_iShopId = null;
00208
00209
00215 protected $_sOutDir = 'out';
00216
00217
00223 protected $_sImageDir = 'img';
00224
00230 protected $_sPictureDir = 'pictures';
00231
00237 protected $_sTemplateDir = 'tpl';
00238
00244 protected $_sResourceDir = 'src';
00245
00251 protected $_blIsSsl = null;
00252
00258 protected $_aAbsDynImageDir = array();
00259
00265 protected $_oActCurrencyObject = null;
00266
00274 public function getConfigParam( $sName )
00275 {
00276 if ( isset( $this->$sName ) ) {
00277 return $this->$sName;
00278 } elseif ( isset ( $this->_aConfigParams[$sName] ) ) {
00279 return $this->_aConfigParams[$sName];
00280 }
00281 }
00282
00291 public function setConfigParam( $sName, $sValue )
00292 {
00293 if ( isset( $this->$sName ) ) {
00294 $this->$sName = $sValue;
00295 } else {
00296 $this->_aConfigParams[$sName] = $sValue;
00297 }
00298 }
00299
00305 public function init()
00306 {
00307 include getShopBasePath().'config.inc.php';
00308 include getShopBasePath().'core/oxconfk.php';
00309
00310
00311 $oFileUtils = oxUtilsFile::getInstance();
00312 $this->sShopDir = $oFileUtils->normalizeDir($this->sShopDir);
00313 $this->sCompileDir = $oFileUtils->normalizeDir($this->sCompileDir);
00314 $this->sShopURL = $oFileUtils->normalizeDir($this->sShopURL);
00315 $this->sShopDir = $oFileUtils->normalizeDir($this->sShopDir);
00316 $this->sSSLShopURL = $oFileUtils->normalizeDir($this->sSSLShopURL);
00317 $this->sAdminSSLURL = $oFileUtils->normalizeDir($this->sAdminSSLURL);
00318
00319
00320
00321 if( !$this->getConfigParam( 'sDefaultLang' ) )
00322 $this->setConfigParam( 'sDefaultLang', 0 );
00323
00324 $blLogChangesInAdmin = $this->getConfigParam( 'blLogChangesInAdmin' );
00325 if( !isset( $blLogChangesInAdmin ) )
00326 $this->setConfigParam( 'blLogChangesInAdmin', false );
00327
00328 $blCheckTemplates = $this->getConfigParam( 'blCheckTemplates' );
00329 if( !isset( $blCheckTemplates ) )
00330 $this->setConfigParam( 'blCheckTemplates', false );
00331
00332 $blAllowArticlesubclass = $this->getConfigParam( 'blAllowArticlesubclass' );
00333 if( !isset( $blAllowArticlesubclass ) )
00334 $this->setConfigParam( 'blAllowArticlesubclass', false );
00335
00336 $iAdminListSize = $this->getConfigParam( 'iAdminListSize' );
00337 if( !isset( $iAdminListSize ) )
00338 $this->setConfigParam( 'iAdminListSize', 9 );
00339
00340
00341 $iPicCount = $this->getConfigParam( 'iPicCount' );
00342 if( !isset( $iPicCount ) )
00343 $this->setConfigParam( 'iPicCount', 12 );
00344
00345 $iZoomPicCount = $this->getConfigParam( 'iZoomPicCount' );
00346 if( !isset( $iZoomPicCount ) )
00347 $this->setConfigParam( 'iZoomPicCount', 4 );
00348
00349
00350 $iMaxShopId = $this->getConfigParam( 'iMaxShopId' );
00351 if( !isset( $iMaxShopId ) )
00352 $this->setConfigParam( 'iMaxShopId', 64 );
00353
00354
00355 $this->setConfigParam( 'blTemplateCaching', false );
00356
00357
00358 global $ADODB_SESS_LIFE;
00359 $ADODB_SESS_LIFE = 1;
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372 $iDBCacheLifeTime = $this->getConfigParam( 'iDBCacheLifeTime' );
00373 if( !isset( $iDBCacheLifeTime ) )
00374 $this->setConfigParam( 'iDBCacheLifeTime', 3600 );
00375
00376 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) )
00377 $this->setConfigParam( 'sSSLShopURL', $sSSLShopURL.'/' );
00378
00379 $sCoreDir = $this->getConfigParam( 'sShopDir' );
00380 $this->setConfigParam( 'sCoreDir', $sCoreDir.'/core/' );
00381
00382 try {
00383
00384 $this->getSession()->start();
00385
00386 $sShopID = $this->getShopId();
00387
00388
00389 $this->_loadVarsFromDb( $sShopID );
00390
00391 } catch ( oxConnectionException $oEx ) {
00392 $oEx->debugOut( $this->iDebug);
00393 if ( defined( 'OXID_PHP_UNIT' ) ) {
00394 return false;
00395 } elseif ( 0 != $this->iDebug ) {
00396 exit( $oEx->getString() );
00397 } else {
00398 header( "HTTP/1.1 500 Internal Server Error");
00399 header( "Location: offline.html");
00400 header( "Connection: close");
00401 }
00402 } catch ( oxCookieException $oEx ) {
00403
00404 oxUtilsView::getInstance()->addErrorToDisplay( $oEx );
00405 oxUtils::getInstance()->redirect( $this->getShopHomeURL() .'cl=start' );
00406 }
00407
00408
00409 $this->_oStart = new oxStart();
00410 $this->_oStart->appInit();
00411 }
00412
00418 public static function getInstance()
00419 {
00420
00421 if ( defined( 'OXID_PHP_UNIT' ) ) {
00422 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00423 return modConfig::$unitMOD;
00424 }
00425 }
00426
00427 if ( !self::$_instance instanceof oxConfig ) {
00428
00429
00430 self::$_instance = new oxConfig();
00431 self::$_instance->init();
00432 }
00433 return self::$_instance;
00434 }
00435
00444 protected function _loadVarsFromDb( $sShopID, $aOnlyVars = null )
00445 {
00446
00447 $sQ = "select oxvarname, oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopID'";
00448
00449 if ( $aOnlyVars !== null ) {
00450 $blSep = false;
00451 $sIn = '';
00452 foreach ( $aOnlyVars as $sField ) {
00453 if ( $blSep ) {
00454 $sIn .= ', ';
00455 }
00456 $sIn .= '"'.$sField.'"';
00457 $blSep = true;
00458 }
00459 $sQ .= ' and oxvarname in ( '.$sIn.' ) ';
00460 }
00461
00462 $oRs = oxDb::getDb()->execute( $sQ );
00463 if ( $oRs != false && $oRs->recordCount() > 0 ) {
00464 while ( !$oRs->EOF ) {
00465 $sVarName = $oRs->fields[0];
00466 $sVarType = $oRs->fields[1];
00467 $sVarVal = $oRs->fields[2];
00468
00469
00470 if ( ( $sVarName == 'sShopURL' || $sVarName == 'sSSLShopURL' ) &&
00471 ( !$sVarVal || $this->isAdmin() === true ) ) {
00472 $oRs->moveNext();
00473 continue;
00474 }
00475
00476 switch ( $sVarType ) {
00477 case 'arr':
00478 case 'aarr':
00479 $this->setConfigParam( $sVarName, unserialize( $sVarVal ) );
00480 break;
00481 case 'bool':
00482 $this->setConfigParam( $sVarName, ( $sVarVal == 'true' || $sVarVal == '1' ) );
00483 break;
00484 default:
00485 $this->setConfigParam( $sVarName, $sVarVal );
00486 }
00487
00488
00489 if ( $sVarType == 'arr' || $sVarType == 'aarr' ) {
00490 } elseif ( $sVarType == 'bool' ) {
00491 } else {
00492
00493 }
00494
00495 $oRs->moveNext();
00496 }
00497 }
00498
00499 }
00500
00506 public function pageClose()
00507 {
00508 return $this->_oStart->pageClose();
00509 }
00510
00524 public static function getParameter( $sName, $blRaw = false )
00525 {
00526 if ( defined( 'OXID_PHP_UNIT' ) ) {
00527 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00528 try{
00529 return modConfig::getParameter( $sName, $blRaw );
00530 } catch( Exception $e ) {
00531
00532 }
00533 }
00534 }
00535
00536 $sValue = null;
00537 if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST[$sName] ) ) {
00538 $sValue = $_POST[$sName];
00539 } elseif ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'GET' && isset( $_GET[$sName] ) ) {
00540 $sValue = $_GET[$sName];
00541
00542 } elseif ( oxSession::hasVar( $sName ) ) {
00543 $sValue = oxSession::getVar( $sName );
00544
00545 } else {
00546 $sValue = null;
00547 }
00548
00549
00550 $blIsAdmin = oxConfig::getInstance()->isAdmin() && oxSession::getVar("blIsAdmin");
00551 if ( $sValue != null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00552 self::checkSpecialChars( $sValue, $blRaw );
00553 }
00554
00555 return $sValue;
00556 }
00557
00565 public function getUploadedFile($sParamName)
00566 {
00567 return $_FILES[$sParamName];
00568 }
00569
00578 public function setGlobalParameter( $sName, $sValue )
00579 {
00580 $this->_aGlobalParams[$sName] = $sValue;
00581 }
00582
00590 public function getGlobalParameter( $sName )
00591 {
00592 if ( isset( $this->_aGlobalParams[$sName] ) ) {
00593 return $this->_aGlobalParams[$sName];
00594 } else {
00595 return null;
00596 }
00597 }
00598
00608 public static function checkSpecialChars( & $sValue, $aRaw = null )
00609 {
00610 if ( is_object( $sValue ) ) {
00611 return $sValue;
00612 }
00613
00614 if ( is_array( $sValue ) ) {
00615 foreach ( $sValue as $sKey => $sVal ) {
00616 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00617 $sValidKey = $sKey;
00618 self::checkSpecialChars( $sValidKey );
00619 self::checkSpecialChars( $sVal );
00620 if ($sValidKey != $sKey) {
00621 unset ($sValue[$sKey]);
00622 }
00623 $sValue[$sValidKey] = $sVal;
00624 }
00625 }
00626 } else {
00627 $sValue = str_replace( array( '&', '<', '>', '"', "'", chr(0), '\\' ),
00628 array( '&', '<', '>', '"', ''', '', '\' ),
00629 $sValue );
00630 }
00631 return $sValue;
00632 }
00633
00639 public function getShopId()
00640 {
00641 if ( $this->_iShopId !== null )
00642 return $this->_iShopId;
00643
00644 $this->_iShopId = $this->getBaseShopId();
00645
00646
00647 oxSession::setVar( 'actshop', $this->_iShopId );
00648 return $this->_iShopId;
00649 }
00650
00658 public function setShopId( $sShopId )
00659 {
00660 oxSession::setVar( 'actshop', $sShopId );
00661 $this->_iShopId = $sShopId;
00662 }
00663
00664
00670 public function isSsl()
00671 {
00672 if (!is_null($this->_blIsSsl)) {
00673 return $this->_blIsSsl;
00674 }
00675
00676 $aServerVars = oxUtilsServer::getInstance()->getServerVar();
00677 $aHttpsServerVar = oxUtilsServer::getInstance()->getServerVar( 'HTTPS' );
00678
00679 $blIsSsl = ( isset( $aHttpsServerVar ) && $this->getConfigParam( 'sSSLShopURL' ) &&
00680 ( $aHttpsServerVar == 'on' || $aHttpsServerVar == '1' ) );
00681
00682
00683 if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00684 ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00685 strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00686 $blIsssl = true;
00687 }
00688
00689
00690 $this->_blIsSsl = $blIsSsl;
00691
00692 return $blIsSsl;
00693 }
00694
00702 public function isCurrentUrl( $sURL )
00703 {
00704 if ( !$sURL ) {
00705 return false;
00706 }
00707
00708 $sCurrentHost = preg_replace( '/\/\w*\.php.*/', '', $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'] );
00709
00710
00711 $sCurrentHost = str_replace( '/', '', $sCurrentHost );
00712 $sURL = str_replace( '/', '', $sURL );
00713
00714
00715 if ( strpos( $sURL, $sCurrentHost ) !== false ) {
00716 return true;
00717 }
00718
00719 return false;
00720 }
00721
00729 public function getShopUrl( $iLang = null )
00730 {
00731 if ( $this->isAdmin() ) {
00732 return $this->getConfigParam( 'sShopURL' );
00733 }
00734
00735
00736 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00737 $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00738 if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) ) {
00739 return $aLanguageURLs[$iLang];
00740 }
00741
00742
00743 $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00744 if ( $sMallShopURL ) {
00745 return $sMallShopURL;
00746 }
00747
00748 return $this->getConfigParam( 'sShopURL' );
00749 }
00750
00758 public function getSslShopUrl( $iLang = null )
00759 {
00760
00761 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00762 $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
00763 if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) ) {
00764 return $aLanguageSSLURLs[$iLang];
00765 }
00766
00767
00768 if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
00769 return $sMallSSLShopURL;
00770 }
00771
00772 if ( ( $sMallShopURL = $this->getConfigParam( '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 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00792 return $sSSLShopURL.'core/utils/';
00793 }
00794 return $this->getConfigParam( 'sShopURL' ).'core/utils/';
00795 }
00796
00802 public function getCurrentShopUrl()
00803 {
00804 if ( $this->isSsl() ) {
00805 return $this->getSslShopUrl();
00806 }
00807 return $this->getShopUrl();
00808 }
00809
00817 public function getShopCurrentUrl( $iLang = null )
00818 {
00819 if ( $this->isSsl() ) {
00820 $sURL = $this->getSSLShopURL( $iLang );
00821 } else {
00822 $sURL = $this->getShopURL( $iLang );
00823 }
00824
00825 return $this->getSession()->url( $sURL.'index.php' );
00826 }
00827
00833 public function getShopHomeUrl()
00834 {
00835 return $this->getSession()->url( $this->getShopUrl().'index.php' );
00836 }
00837
00843 public function getShopSecureHomeUrl()
00844 {
00845 return $this->getSession()->url( $this->getSslShopUrl().'index.php' );
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 , $blNativeImg = false, $blAdmin = null )
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
01049 public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true )
01050 {
01051 $sBase = $this->getOutDir( $blAbsolute );
01052 $sAbsBase = $this->getOutDir();
01053
01054 $oLang = oxLang::getInstance();
01055
01056 if ( is_null($iLang) ) {
01057 $iLang = $oLang->getEditLanguage();
01058 }
01059
01060 $sLang = $oLang->getLanguageAbbr( $iLang );
01061
01062 if ( is_null($iShop) ) {
01063 $iShop = $this->getShopId();
01064 }
01065
01066 if ( is_null($sTheme) ) {
01067 $sTheme = $this->getConfigParam( 'sTheme' );
01068 }
01069
01070 if ( $blAdmin ) {
01071 $sTheme = 'admin';
01072 }
01073
01074
01075 $sPath = "$sTheme/$iShop/$sLang/$sDir/$sFile";
01076 $sCacheKey = $sPath . "_$blAbsolute";
01077
01078 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01079 return $sReturn;
01080 }
01081
01082 $sReturn = false;
01083
01084
01085 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01086 $sReturn = $sBase . $sPath;
01087 }
01088
01089
01090 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01091 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01092 $sReturn = $sBase . $sPath;
01093 }
01094
01095
01096
01097 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01098 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01099 $sReturn = $sBase . $sPath;
01100 }
01101
01102
01103 $sPath = "$sTheme/$sDir/$sFile";
01104 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01105 $sReturn = $sBase . $sPath;
01106 }
01107
01108
01109 $sPath = "$sLang/$sDir/$sFile";
01110 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01111 $sReturn = $sBase . $sPath;
01112 }
01113
01114
01115 $sPath = "$sDir/$sFile";
01116 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01117 $sReturn = $sBase . $sPath;
01118 }
01119
01120 if ( !$sReturn ) {
01121
01122 }
01123
01124
01125 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01126
01127 return $sReturn;
01128 }
01129
01144 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01145 {
01146 $sUrl = str_replace(
01147 $this->getOutDir(),
01148 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01149 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01150 );
01151 return $sUrl;
01152 }
01153
01162 public function getImagePath( $sFile, $blAdmin = false )
01163 {
01164 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01165 }
01166
01176 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01177 {
01178 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01179 return $this->getUrl( null , $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01180 }
01181
01189 public function getImageDir( $blAdmin = false )
01190 {
01191 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01192 }
01193
01202 public function getPicturePath($sFile, $blAdmin = false )
01203 {
01204 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01205 }
01206
01218 public function getPictureUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null )
01219 {
01220 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01221
01222 if ( $this->isSsl() ) {
01223 $sAltUrl = str_replace( 'http://', 'https://', $sAltUrl );
01224 }
01225
01226 if ( !is_null( $sFile ) ) {
01227 $sAltUrl .= $sFile;
01228 }
01229
01230 return $sAltUrl;
01231 }
01232 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, null, $iLang, $iShopId );
01233 if ( $sFile && $this->getConfigParam('blFormerTplSupport') ) {
01234 $sUrl = str_replace( $this->getPictureUrl( null, $blAdmin, $blSSL, $iLang, $iShopId ), '', $sUrl );
01235 }
01236 return $sUrl;
01237 }
01238
01246 public function getPictureDir( $blAdmin )
01247 {
01248 return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01249 }
01250
01259 public function getTemplatePath( $sFile, $blAdmin )
01260 {
01261 return $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01262 }
01263
01271 public function getTemplateDir( $blAdmin = false )
01272 {
01273 return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01274 }
01275
01286 public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01287 {
01288 return $this->getUrl( $sFile, $this->_sTemplateDir, $blAdmin, $blSSL, false, $iLang );
01289 }
01290
01298 public function getTemplateBase( $blAdmin = false )
01299 {
01300
01301 return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01302 }
01303
01312 public function getResourcePath($sFile, $blAdmin = false )
01313 {
01314 return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01315 }
01316
01327 public function getResourceUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null )
01328 {
01329 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, false, $iLang );
01330 }
01331
01339 public function getResourceDir( $blAdmin )
01340 {
01341 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01342 }
01343
01353 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01354 {
01355 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01356 }
01357
01365 public function getLanguageDir( $blAdmin )
01366 {
01367 return $this->getDir( null, null, $blAdmin );
01368 }
01369
01377 public function getAbsImageDir()
01378 {
01379 return $this->getImageDir();
01380 }
01381
01392 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01393 {
01394 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437 }
01438
01448 public function getAbsDynImageDir( $sOverrideShopId = null )
01449 {
01450 return $this->getPictureDir(false);
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465 }
01466
01477 public function getTemplateFile( $sTemplate, $blAdmin = false )
01478 {
01479 return $this->getTemplatePath( $sTemplate, $blAdmin );
01480 }
01481
01491 public function getBaseTemplateDir( $blAdmin = false )
01492 {
01493 return $this->getResourceUrl( null, $blAdmin );
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505 }
01506
01516 public function getBaseTplDir( $blAdmin = false )
01517 {
01518
01519 return $this->getResourceUrl( null, $blAdmin);
01520 }
01521
01529 public function getCurrencyArray( $iCurrency = null )
01530 {
01531 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01532 if ( !is_array( $aConfCurrencies ) ) {
01533 return array();
01534 }
01535
01536 if ( defined( 'OXID_PHP_UNIT' ) ) {
01537 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01538 try{
01539 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01540 if ( isset( $aAltCurrencies ) ) {
01541 $aConfCurrencies = $aAltCurrencies;
01542 }
01543 } catch( Exception $e ) {
01544
01545 }
01546 }
01547 }
01548
01549
01550 $aCurrencies = array();
01551 reset( $aConfCurrencies );
01552 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01553 if ( $val ) {
01554 $oCur = new oxStdClass();
01555 $oCur->id = $key;
01556 $sCur = explode( '@', $val);
01557 $oCur->name = trim( $sCur[0] );
01558 $oCur->rate = trim( $sCur[1] );
01559 $oCur->dec = trim( $sCur[2] );
01560 $oCur->thousand = trim( $sCur[3] );
01561 $oCur->sign = trim( $sCur[4] );
01562 $oCur->decimal = trim( $sCur[5] );
01563
01564
01565 if ( isset( $sCur[6] ) )
01566 $oCur->side = trim($sCur[6]);
01567
01568 if ( isset( $iCurrency) && $key == $iCurrency ) {
01569 $oCur->selected = 1;
01570 } else {
01571 $oCur->selected = 0;
01572 }
01573 $aCurrencies[$key]= $oCur;
01574 }
01575
01576
01577 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01578 break;
01579 }
01580 }
01581 return $aCurrencies;
01582 }
01583
01591 public function getCurrencyObject( $sName )
01592 {
01593 $aSearch = $this->getCurrencyArray();
01594 foreach ( $aSearch as $oCur ) {
01595 if ( $oCur->name == $sName ) {
01596 return $oCur;
01597 }
01598 }
01599 }
01600
01606 public function isDemoShop()
01607 {
01608 return $this->getConfigParam('blDemoShop');
01609 }
01610
01616 public function getEdition()
01617 {
01618 return $this->getActiveShop()->oxshops__oxedition->value;
01619 }
01620
01626 public function getFullEdition()
01627 {
01628 $sEdition = $this->getEdition();
01629
01630 if ($sEdition == "CE") {
01631 return "Community Edition";
01632 }
01633
01634
01635
01636 return $sEdition;
01637 }
01638
01644 public function getVersion()
01645 {
01646 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01647 return $sVersion;
01648 }
01649
01655 public function getRevision()
01656 {
01657 try {
01658 $sFileName = getShopBasePath() . "/pkg.rev";
01659 $iRev = (int) trim(@file_get_contents($sFileName));
01660 } catch (Exception $e) {
01661 return false;
01662 }
01663
01664 if (!$iRev) {
01665 return false;
01666 }
01667
01668 return $iRev;
01669 }
01670
01671
01677 public function isMall()
01678 {
01679
01680 return false;
01681 }
01682
01692 public function detectVersion()
01693 {
01694 }
01695
01696
01697
01708 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01709 {
01710 if ( !$sShopId ) {
01711 $sShopId = $this->getShopId();
01712 }
01713
01714 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01715 oxDb::getDb()->Execute( $sQ );
01716 $sUid = oxUtilsObject::getInstance()->generateUID();
01717
01718 $sUid = mysql_real_escape_string($sUid);
01719 $sShopId = mysql_real_escape_string($sShopId);
01720 $sVarName = mysql_real_escape_string($sVarName);
01721 $sVarVal = mysql_real_escape_string($sVarVal);
01722
01723 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01724 values('$sUid', '$sShopId', '$sVarName', '$sVarType', ENCODE( '$sVarVal', '".$this->getConfigParam('sConfigKey')."'))";
01725
01726 oxDb::getDb()->Execute($sQ);
01727 }
01728
01737 public function getShopConfVar( $sVarName, $sShopId = null )
01738 {
01739 if ( !$sShopId ) {
01740 $sShopId = $this->getShopId();
01741 }
01742
01743 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01744 $oRs = oxDb::getDb(true)->Execute( $sQ );
01745
01746 $sValue = null;
01747 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01748 $sVarType = $oRs->fields['oxvartype'];
01749 $sVarVal = $oRs->fields['oxvarvalue'];
01750 switch ( $sVarType ) {
01751 case 'arr':
01752 case 'aarr':
01753 $sValue = unserialize( $sVarVal );
01754 break;
01755 case 'bool':
01756 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01757 break;
01758 default:
01759 $sValue = $sVarVal;
01760 }
01761 }
01762 return $sValue;
01763 }
01764
01770 public function isProductiveMode()
01771 {
01772 $blProductive = false;
01773
01774 $blProductive = $this->getConfigParam( 'blProductive' );
01775 if ( !isset( $blProductive ) ) {
01776 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01777 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01778 $this->setConfigParam( 'blProductive', $blProductive );
01779 }
01780
01781 return $blProductive;
01782 }
01783
01784
01785
01791 public function getBaseShopId()
01792 {
01793
01794 return 'oxbaseshop';
01795 }
01796
01802 public function getActiveShop()
01803 {
01804 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() )
01805 return $this->_oActShop;
01806
01807 $this->_oActShop = oxNew( 'oxshop' );
01808 $this->_oActShop->load( $this->getShopId() );
01809 return $this->_oActShop;
01810 }
01811
01817 public function getActiveView()
01818 {
01819 if ( $this->_oActView != null ) {
01820 return $this->_oActView;
01821 }
01822
01823 $this->_oActView = oxNew( 'oxubase' );
01824 return $this->_oActView;
01825 }
01826
01834 public function setActiveView( $oView )
01835 {
01836 $this->_oActView = $oView;
01837 }
01838 }