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 protected $blSessionEnforceCookies = null;
00120
00126
00127
00137 protected $blNativeImages = true;
00138
00144 protected $aMultiShopTables = array( 'oxarticles', 'oxdiscount', 'oxcategories', 'oxattribute',
00145 'oxlinks', 'oxvoucherseries', 'oxmanufacturers',
00146 'oxnews', 'oxselectlist', 'oxwrapping',
00147 'oxdeliveryset', 'oxdelivery', 'oxvendor', 'oxobject2category');
00148
00154 private static $_instance = null;
00155
00161 private $_oStart = null;
00162
00163
00169 protected $_oActShop = null;
00170
00178 protected $_oActView = null;
00179
00185 protected $_aGlobalParams = array();
00186
00192 protected $_aConfigParams = array();
00193
00199 protected $_iLanguageId = null;
00200
00206 protected $_iShopId = null;
00207
00208
00214 protected $_sOutDir = 'out';
00215
00221 protected $_sImageDir = 'img';
00222
00228 protected $_sPictureDir = 'pictures';
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', 12 );
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( $this->iDebug);
00387 if ( defined( 'OXID_PHP_UNIT' ) ) {
00388 return false;
00389 } elseif ( 0 != $this->iDebug ) {
00390 exit( $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' );
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 }
00481
00482
00483 if ( $sVarType == 'arr' || $sVarType == 'aarr' ) {
00484 } elseif ( $sVarType == 'bool' ) {
00485 } else {
00486
00487 }
00488
00489 $oRs->moveNext();
00490 }
00491 }
00492
00493 }
00494
00500 public function pageClose()
00501 {
00502 return $this->_oStart->pageClose();
00503 }
00504
00518 public static function getParameter( $sName, $blRaw = false )
00519 {
00520 if ( defined( 'OXID_PHP_UNIT' ) ) {
00521 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00522 try{
00523 return modConfig::getParameter( $sName, $blRaw );
00524 } catch( Exception $e ) {
00525
00526 }
00527 }
00528 }
00529
00530 $sValue = null;
00531 if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST[$sName] ) ) {
00532 $sValue = $_POST[$sName];
00533 } elseif ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'GET' && isset( $_GET[$sName] ) ) {
00534 $sValue = $_GET[$sName];
00535
00536 } elseif ( oxSession::hasVar( $sName ) ) {
00537 $sValue = oxSession::getVar( $sName );
00538
00539 } else {
00540 $sValue = null;
00541 }
00542
00543
00544 $blIsAdmin = oxConfig::getInstance()->isAdmin() && oxSession::getVar("blIsAdmin");
00545 if ( $sValue != null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00546 self::checkSpecialChars( $sValue, $blRaw );
00547 }
00548
00549 return $sValue;
00550 }
00551
00559 public function getUploadedFile($sParamName)
00560 {
00561 return $_FILES[$sParamName];
00562 }
00563
00572 public function setGlobalParameter( $sName, $sValue )
00573 {
00574 $this->_aGlobalParams[$sName] = $sValue;
00575 }
00576
00584 public function getGlobalParameter( $sName )
00585 {
00586 if ( isset( $this->_aGlobalParams[$sName] ) ) {
00587 return $this->_aGlobalParams[$sName];
00588 } else {
00589 return null;
00590 }
00591 }
00592
00602 public static function checkSpecialChars( & $sValue, $aRaw = null )
00603 {
00604 if ( is_object( $sValue ) ) {
00605 return $sValue;
00606 }
00607
00608 if ( is_array( $sValue ) ) {
00609 foreach ( $sValue as $sKey => $sVal ) {
00610 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00611 $sValidKey = $sKey;
00612 self::checkSpecialChars( $sValidKey );
00613 self::checkSpecialChars( $sVal );
00614 if ($sValidKey != $sKey) {
00615 unset ($sValue[$sKey]);
00616 }
00617 $sValue[$sValidKey] = $sVal;
00618 }
00619 }
00620 } else {
00621 $sValue = str_replace( array( '&', '<', '>', '"', "'", chr(0), '\\' ),
00622 array( '&', '<', '>', '"', ''', '', '\' ),
00623 $sValue );
00624 }
00625 return $sValue;
00626 }
00627
00633 public function getShopId()
00634 {
00635 if ( $this->_iShopId !== null )
00636 return $this->_iShopId;
00637
00638 $this->_iShopId = $this->getBaseShopId();
00639
00640
00641 oxSession::setVar( 'actshop', $this->_iShopId );
00642 return $this->_iShopId;
00643 }
00644
00652 public function setShopId( $sShopId )
00653 {
00654 oxSession::setVar( 'actshop', $sShopId );
00655 $this->_iShopId = $sShopId;
00656 }
00657
00658
00664 public function isSsl()
00665 {
00666 if ( is_null( $this->_blIsSsl ) ) {
00667
00668 $myUtilsServer = oxUtilsServer::getInstance();
00669 $aServerVars = $myUtilsServer->getServerVar();
00670 $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00671
00672 $this->_blIsSsl = ( isset( $aHttpsServerVar ) && $this->getConfigParam( 'sSSLShopURL' ) &&
00673 ( $aHttpsServerVar == 'on' || $aHttpsServerVar == '1' ) );
00674
00675
00676 if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00677 ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00678 strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00679 $this->_blIsSsl = true;
00680 }
00681 }
00682
00683 return $this->_blIsSsl;
00684 }
00685
00693 public function isCurrentUrl( $sURL )
00694 {
00695 if ( !$sURL ) {
00696 return false;
00697 }
00698
00699 $sCurrentHost = preg_replace( '/\/\w*\.php.*/', '', $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'] );
00700
00701
00702 $sCurrentHost = str_replace( '/', '', $sCurrentHost );
00703 $sURL = str_replace( '/', '', $sURL );
00704
00705
00706 if ( getStr()->strpos( $sURL, $sCurrentHost ) !== false ) {
00707 return true;
00708 }
00709
00710 return false;
00711 }
00712
00721 public function getShopUrl( $iLang = null, $blAdmin = null )
00722 {
00723 $blAdmin = isset( $blAdmin ) ? $blAdmin : $this->isAdmin();
00724 if ( $blAdmin ) {
00725 return $this->getConfigParam( 'sShopURL' );
00726 }
00727
00728
00729 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00730 $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00731 if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) && !empty( $aLanguageURLs[$iLang] ) ) {
00732 $aLanguageURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageURLs[$iLang] );
00733 return $aLanguageURLs[$iLang];
00734 }
00735
00736
00737 $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00738 if ( $sMallShopURL ) {
00739 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00740 return $sMallShopURL;
00741 }
00742
00743 return $this->getConfigParam( 'sShopURL' );
00744 }
00745
00753 public function getSslShopUrl( $iLang = null )
00754 {
00755
00756 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00757 $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
00758 if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) && !empty( $aLanguageSSLURLs[$iLang] ) ) {
00759 $aLanguageSSLURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageSSLURLs[$iLang] );
00760 return $aLanguageSSLURLs[$iLang];
00761 }
00762
00763
00764 if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
00765 $sMallSSLShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallSSLShopURL );
00766 return $sMallSSLShopURL;
00767 }
00768
00769 if ( ( $sMallShopURL = $this->getConfigParam( 'sMallShopURL' ) ) ) {
00770 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00771 return $sMallShopURL;
00772 }
00773
00774
00775 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00776 return $sSSLShopURL;
00777 }
00778
00779 return $this->getShopUrl( $iLang );
00780 }
00781
00787 public function getCoreUtilsUrl()
00788 {
00789 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00790 return $sSSLShopURL.'core/utils/';
00791 }
00792 return $this->getConfigParam( 'sShopURL' ).'core/utils/';
00793 }
00794
00800 public function getCurrentShopUrl()
00801 {
00802 if ( $this->isSsl() ) {
00803 return $this->getSslShopUrl();
00804 }
00805 return $this->getShopUrl();
00806 }
00807
00815 public function getShopCurrentUrl( $iLang = null )
00816 {
00817 if ( $this->isSsl() ) {
00818 $sURL = $this->getSSLShopURL( $iLang );
00819 } else {
00820 $sURL = $this->getShopURL( $iLang );
00821 }
00822
00823 return $this->getSession()->url( $sURL.'index.php' );
00824 }
00825
00834 public function getShopHomeUrl( $iLang = null, $blAdmin = null )
00835 {
00836 return $this->getSession()->url( $this->getShopUrl( $iLang, $blAdmin).'index.php' );
00837 }
00838
00844 public function getShopSecureHomeUrl()
00845 {
00846 return $this->getSession()->url( $this->getSslShopUrl().'index.php' );
00847 }
00848
00854 public function getShopCurrency()
00855 {
00856 return (int) oxConfig::getParameter( 'currency' );
00857 }
00858
00864 public function getActShopCurrencyObject()
00865 {
00866
00867
00868 if ( !defined( 'OXID_PHP_UNIT' ) ) {
00869 if (!is_null($this->_oActCurrencyObject)) {
00870 return $this->_oActCurrencyObject;
00871 }
00872 }
00873
00874 $iCur = oxConfig::getParameter( 'cur' );
00875 if ( !isset( $iCur ) ) {
00876 $iCur = $this->getShopCurrency();
00877 }
00878
00879 $aCurrencies = $this->getCurrencyArray();
00880 if ( !isset( $aCurrencies[$iCur] ) ) {
00881 return $this->_oActCurrencyObject = reset( $aCurrencies );
00882 }
00883
00884 return $this->_oActCurrencyObject = $aCurrencies[$iCur];
00885 }
00886
00894 public function setActShopCurrency( $iCur )
00895 {
00896 $aCurrencies = $this->getCurrencyArray();
00897 if ( isset( $aCurrencies[$iCur] ) ) {
00898 oxSession::setVar( 'currency', $iCur );
00899 $this->_oActCurrencyObject = null;
00900 }
00901 }
00902
00903
00913 public function getNoSslImageDir( $blAdmin = false )
00914 {
00915 return $this->getImageUrl( $blAdmin, false );
00916 }
00917
00925 public function getAbsAdminImageDir()
00926 {
00927 return $this->getImageDir( true );
00928
00929 }
00930
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
00997
01005 public function getOutDir( $blAbsolute = true)
01006 {
01007 if ($blAbsolute) {
01008 return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01009 } else {
01010 return $this->_sOutDir.'/';
01011 }
01012 }
01013
01023 public function getOutUrl( $blSSL = null , $blNativeImg = false, $blAdmin = null )
01024 {
01025 $blSSL = is_null($blSSL)?$this->isSsl():$blSSL;
01026 $blAdmin = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01027
01028 if ( $blSSL ) {
01029 $sUrl = ($blNativeImg && !$blAdmin )?$this->getSslShopUrl():$this->getConfigParam( 'sSSLShopURL');
01030 } else {
01031 $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01032 }
01033
01034 return $sUrl.$this->_sOutDir.'/';
01035 }
01036
01050 public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true )
01051 {
01052 $sBase = $this->getOutDir( $blAbsolute );
01053 $sAbsBase = $this->getOutDir();
01054
01055 $oLang = oxLang::getInstance();
01056
01057 if ( is_null($iLang) ) {
01058 $iLang = $oLang->getEditLanguage();
01059 }
01060
01061 $sLang = $oLang->getLanguageAbbr( $iLang );
01062
01063 if ( is_null($iShop) ) {
01064 $iShop = $this->getShopId();
01065 }
01066
01067 if ( is_null($sTheme) ) {
01068 $sTheme = $this->getConfigParam( 'sTheme' );
01069 }
01070
01071 if ( $blAdmin ) {
01072 $sTheme = 'admin';
01073 }
01074
01075
01076 $sPath = "$sTheme/$iShop/$sLang/$sDir/$sFile";
01077 $sCacheKey = $sPath . "_$blAbsolute";
01078
01079 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01080 return $sReturn;
01081 }
01082
01083 $sReturn = false;
01084
01085
01086 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01087 $sReturn = $sBase . $sPath;
01088 }
01089
01090
01091 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01092 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01093 $sReturn = $sBase . $sPath;
01094 }
01095
01096
01097
01098 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01099 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01100 $sReturn = $sBase . $sPath;
01101 }
01102
01103
01104 $sPath = "$sTheme/$sDir/$sFile";
01105 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01106 $sReturn = $sBase . $sPath;
01107 }
01108
01109
01110 $sPath = "$sLang/$sDir/$sFile";
01111 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01112 $sReturn = $sBase . $sPath;
01113 }
01114
01115
01116 $sPath = "$sDir/$sFile";
01117 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01118 $sReturn = $sBase . $sPath;
01119 }
01120
01121 if ( !$sReturn ) {
01122
01123 }
01124
01125
01126 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01127
01128 return $sReturn;
01129 }
01130
01145 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01146 {
01147 $sUrl = str_replace(
01148 $this->getOutDir(),
01149 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01150 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01151 );
01152 return $sUrl;
01153 }
01154
01163 public function getImagePath( $sFile, $blAdmin = false )
01164 {
01165 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01166 }
01167
01177 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01178 {
01179 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01180 return $this->getUrl( null, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01181 }
01182
01190 public function getImageDir( $blAdmin = false )
01191 {
01192 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01193 }
01194
01203 public function getPicturePath($sFile, $blAdmin = false )
01204 {
01205 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01206 }
01207
01219 public function getPictureUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null )
01220 {
01221 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01222
01223 if ( $this->isSsl() ) {
01224 $sAltUrl = str_replace( 'http://', 'https://', $sAltUrl );
01225 }
01226
01227 if ( !is_null( $sFile ) ) {
01228 $sAltUrl .= $sFile;
01229 }
01230
01231 return $sAltUrl;
01232 }
01233 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, null, $iLang, $iShopId );
01234 if ( $sFile && $this->getConfigParam('blFormerTplSupport') ) {
01235 $sUrl = str_replace( $this->getPictureUrl( null, $blAdmin, $blSSL, $iLang, $iShopId ), '', $sUrl );
01236 }
01237
01238 if (!$sUrl) {
01239 return $this->getTemplateUrl()."../".$this->_sPictureDir."/0/nopic.jpg";
01240 }
01241 return $sUrl;
01242 }
01243
01251 public function getPictureDir( $blAdmin )
01252 {
01253 return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01254 }
01255
01264 public function getTemplatePath( $sFile, $blAdmin )
01265 {
01266 return $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01267 }
01268
01276 public function getTemplateDir( $blAdmin = false )
01277 {
01278 return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01279 }
01280
01291 public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01292 {
01293 return $this->getUrl( $sFile, $this->_sTemplateDir, $blAdmin, $blSSL, false, $iLang );
01294 }
01295
01303 public function getTemplateBase( $blAdmin = false )
01304 {
01305
01306 return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01307 }
01308
01317 public function getResourcePath($sFile, $blAdmin = false )
01318 {
01319 return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01320 }
01321
01332 public function getResourceUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null )
01333 {
01334 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, false, $iLang );
01335 }
01336
01344 public function getResourceDir( $blAdmin )
01345 {
01346 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01347 }
01348
01358 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01359 {
01360 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01361 }
01362
01370 public function getLanguageDir( $blAdmin )
01371 {
01372 return $this->getDir( null, null, $blAdmin );
01373 }
01374
01382 public function getAbsImageDir()
01383 {
01384 return $this->getImageDir();
01385 }
01386
01397 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01398 {
01399 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
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
01439
01440
01441
01442 }
01443
01453 public function getAbsDynImageDir( $sOverrideShopId = null )
01454 {
01455 return $this->getPictureDir(false);
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470 }
01471
01482 public function getTemplateFile( $sTemplate, $blAdmin = false )
01483 {
01484 return $this->getTemplatePath( $sTemplate, $blAdmin );
01485 }
01486
01496 public function getBaseTemplateDir( $blAdmin = false )
01497 {
01498 return $this->getResourceUrl( null, $blAdmin );
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510 }
01511
01521 public function getBaseTplDir( $blAdmin = false )
01522 {
01523
01524 return $this->getResourceUrl( null, $blAdmin);
01525 }
01526
01534 public function getCurrencyArray( $iCurrency = null )
01535 {
01536 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01537 if ( !is_array( $aConfCurrencies ) ) {
01538 return array();
01539 }
01540
01541 if ( defined( 'OXID_PHP_UNIT' ) ) {
01542 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01543 try{
01544 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01545 if ( isset( $aAltCurrencies ) ) {
01546 $aConfCurrencies = $aAltCurrencies;
01547 }
01548 } catch( Exception $e ) {
01549
01550 }
01551 }
01552 }
01553
01554
01555 $aCurrencies = array();
01556 reset( $aConfCurrencies );
01557 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01558 if ( $val ) {
01559 $oCur = new oxStdClass();
01560 $oCur->id = $key;
01561 $sCur = explode( '@', $val);
01562 $oCur->name = trim( $sCur[0] );
01563 $oCur->rate = trim( $sCur[1] );
01564 $oCur->dec = trim( $sCur[2] );
01565 $oCur->thousand = trim( $sCur[3] );
01566 $oCur->sign = trim( $sCur[4] );
01567 $oCur->decimal = trim( $sCur[5] );
01568
01569
01570 if ( isset( $sCur[6] ) ) {
01571 $oCur->side = trim($sCur[6]);
01572 }
01573
01574 if ( isset( $iCurrency) && $key == $iCurrency ) {
01575 $oCur->selected = 1;
01576 } else {
01577 $oCur->selected = 0;
01578 }
01579 $aCurrencies[$key]= $oCur;
01580 }
01581
01582
01583 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01584 break;
01585 }
01586 }
01587 return $aCurrencies;
01588 }
01589
01597 public function getCurrencyObject( $sName )
01598 {
01599 $aSearch = $this->getCurrencyArray();
01600 foreach ( $aSearch as $oCur ) {
01601 if ( $oCur->name == $sName ) {
01602 return $oCur;
01603 }
01604 }
01605 }
01606
01612 public function isDemoShop()
01613 {
01614 return $this->getConfigParam('blDemoShop');
01615 }
01616
01622 public function getEdition()
01623 {
01624 return "CE";
01625
01626
01627 }
01628
01634 public function getFullEdition()
01635 {
01636 $sEdition = $this->getEdition();
01637
01638 if ($sEdition == "CE") {
01639 return "Community Edition";
01640 }
01641
01642
01643
01644 return $sEdition;
01645 }
01646
01652 public function getVersion()
01653 {
01654 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01655 return $sVersion;
01656 }
01657
01663 public function getRevision()
01664 {
01665 try {
01666 $sFileName = getShopBasePath() . "/pkg.rev";
01667 $iRev = (int) trim(@file_get_contents($sFileName));
01668 } catch (Exception $e) {
01669 return false;
01670 }
01671
01672 if (!$iRev) {
01673 return false;
01674 }
01675
01676 return $iRev;
01677 }
01678
01679
01685 public function isMall()
01686 {
01687
01688 return false;
01689 }
01690
01700 public function detectVersion()
01701 {
01702 }
01703
01704
01705
01716 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01717 {
01718 if ( !$sShopId ) {
01719 $sShopId = $this->getShopId();
01720 }
01721
01722 $oDb = oxDb::getDb();
01723 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01724 $oDb->Execute( $sQ );
01725 $sUid = oxUtilsObject::getInstance()->generateUID();
01726
01727 $sUid = mysql_real_escape_string($sUid);
01728 $sShopId = mysql_real_escape_string($sShopId);
01729 $sVarName = mysql_real_escape_string($sVarName);
01730 $sVarVal = mysql_real_escape_string($sVarVal);
01731
01732 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01733 values('$sUid', '$sShopId', '$sVarName', '$sVarType', ENCODE( '$sVarVal', '".$this->getConfigParam('sConfigKey')."'))";
01734
01735 $oDb->Execute($sQ);
01736 }
01737
01746 public function getShopConfVar( $sVarName, $sShopId = null )
01747 {
01748 if ( !$sShopId ) {
01749 $sShopId = $this->getShopId();
01750 }
01751
01752 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01753 $oRs = oxDb::getDb(true)->Execute( $sQ );
01754
01755 $sValue = null;
01756 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01757 $sVarType = $oRs->fields['oxvartype'];
01758 $sVarVal = $oRs->fields['oxvarvalue'];
01759 switch ( $sVarType ) {
01760 case 'arr':
01761 case 'aarr':
01762 $sValue = unserialize( $sVarVal );
01763 break;
01764 case 'bool':
01765 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01766 break;
01767 default:
01768 $sValue = $sVarVal;
01769 }
01770 }
01771 return $sValue;
01772 }
01773
01779 public function isProductiveMode()
01780 {
01781 $blProductive = false;
01782
01783 $blProductive = $this->getConfigParam( 'blProductive' );
01784 if ( !isset( $blProductive ) ) {
01785 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01786 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01787 $this->setConfigParam( 'blProductive', $blProductive );
01788 }
01789
01790 return $blProductive;
01791 }
01792
01793
01794
01800 public function getBaseShopId()
01801 {
01802
01803 return 'oxbaseshop';
01804 }
01805
01811 public function getActiveShop()
01812 {
01813 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01814 $this->_oActShop->getLanguage() == oxLang::getInstance()->getBaseLanguage() ) {
01815 return $this->_oActShop;
01816 }
01817
01818 $this->_oActShop = oxNew( 'oxshop' );
01819 $this->_oActShop->load( $this->getShopId() );
01820 return $this->_oActShop;
01821 }
01822
01828 public function getActiveView()
01829 {
01830 if ( $this->_oActView != null ) {
01831 return $this->_oActView;
01832 }
01833
01834 $this->_oActView = oxNew( 'oxubase' );
01835 return $this->_oActView;
01836 }
01837
01845 public function setActiveView( $oView )
01846 {
01847 $this->_oActView = $oView;
01848 }
01849
01855 public function isUtf()
01856 {
01857 return ( bool ) $this->getConfigParam( 'iUtfMode' );
01858 }
01859 }