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 $newValue = array();
00610 foreach ( $sValue as $sKey => $sVal ) {
00611 $sValidKey = $sKey;
00612 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00613 self::checkSpecialChars( $sValidKey );
00614 self::checkSpecialChars( $sVal );
00615 if ($sValidKey != $sKey) {
00616 unset ($sValue[$sKey]);
00617 }
00618 }
00619 $newValue[$sValidKey] = $sVal;
00620 }
00621 $sValue = $newValue;
00622 } else {
00623 $sValue = str_replace( array( '&', '<', '>', '"', "'", chr(0), '\\' ),
00624 array( '&', '<', '>', '"', ''', '', '\' ),
00625 $sValue );
00626 }
00627 return $sValue;
00628 }
00629
00635 public function getShopId()
00636 {
00637 if ( $this->_iShopId !== null )
00638 return $this->_iShopId;
00639
00640 $this->_iShopId = $this->getBaseShopId();
00641
00642
00643 oxSession::setVar( 'actshop', $this->_iShopId );
00644 return $this->_iShopId;
00645 }
00646
00654 public function setShopId( $sShopId )
00655 {
00656 oxSession::setVar( 'actshop', $sShopId );
00657 $this->_iShopId = $sShopId;
00658 }
00659
00660
00666 public function isSsl()
00667 {
00668 if ( is_null( $this->_blIsSsl ) ) {
00669
00670 $myUtilsServer = oxUtilsServer::getInstance();
00671 $aServerVars = $myUtilsServer->getServerVar();
00672 $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00673
00674 $this->_blIsSsl = ( isset( $aHttpsServerVar ) && $this->getConfigParam( 'sSSLShopURL' ) &&
00675 ( $aHttpsServerVar == 'on' || $aHttpsServerVar == '1' ) );
00676
00677
00678 if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00679 ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00680 strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00681 $this->_blIsSsl = true;
00682 }
00683 }
00684
00685 return $this->_blIsSsl;
00686 }
00687
00695 public function isCurrentUrl( $sURL )
00696 {
00697 if ( !$sURL ) {
00698 return false;
00699 }
00700
00701 $sCurrentHost = preg_replace( '/\/\w*\.php.*/', '', $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'] );
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 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
00836 public function getShopHomeUrl( $iLang = null, $blAdmin = null )
00837 {
00838 return $this->getSession()->url( $this->getShopUrl( $iLang, $blAdmin).'index.php' );
00839 }
00840
00846 public function getShopSecureHomeUrl()
00847 {
00848 return $this->getSession()->url( $this->getSslShopUrl().'index.php' );
00849 }
00850
00856 public function getShopCurrency()
00857 {
00858 return (int) oxConfig::getParameter( 'currency' );
00859 }
00860
00866 public function getActShopCurrencyObject()
00867 {
00868
00869
00870 if ( !defined( 'OXID_PHP_UNIT' ) ) {
00871 if (!is_null($this->_oActCurrencyObject)) {
00872 return $this->_oActCurrencyObject;
00873 }
00874 }
00875
00876 $iCur = oxConfig::getParameter( 'cur' );
00877 if ( !isset( $iCur ) ) {
00878 $iCur = $this->getShopCurrency();
00879 }
00880
00881 $aCurrencies = $this->getCurrencyArray();
00882 if ( !isset( $aCurrencies[$iCur] ) ) {
00883 return $this->_oActCurrencyObject = reset( $aCurrencies );
00884 }
00885
00886 return $this->_oActCurrencyObject = $aCurrencies[$iCur];
00887 }
00888
00896 public function setActShopCurrency( $iCur )
00897 {
00898 $aCurrencies = $this->getCurrencyArray();
00899 if ( isset( $aCurrencies[$iCur] ) ) {
00900 oxSession::setVar( 'currency', $iCur );
00901 $this->_oActCurrencyObject = null;
00902 }
00903 }
00904
00905
00915 public function getNoSslImageDir( $blAdmin = false )
00916 {
00917 return $this->getImageUrl( $blAdmin, false );
00918 }
00919
00927 public function getAbsAdminImageDir()
00928 {
00929 return $this->getImageDir( true );
00930
00931 }
00932
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
00998
00999
01007 public function getOutDir( $blAbsolute = true)
01008 {
01009 if ($blAbsolute) {
01010 return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01011 } else {
01012 return $this->_sOutDir.'/';
01013 }
01014 }
01015
01025 public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01026 {
01027 $blSSL = is_null($blSSL)?$this->isSsl():$blSSL;
01028 $blAdmin = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01029
01030 if ( $blSSL ) {
01031 $sUrl = ($blNativeImg && !$blAdmin )?$this->getSslShopUrl():$this->getConfigParam( 'sSSLShopURL');
01032 } else {
01033 $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01034 }
01035
01036 return $sUrl.$this->_sOutDir.'/';
01037 }
01038
01052 public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true )
01053 {
01054 $sBase = $this->getOutDir( $blAbsolute );
01055 $sAbsBase = $this->getOutDir();
01056
01057 $oLang = oxLang::getInstance();
01058
01059 if ( is_null($iLang) ) {
01060 $iLang = $oLang->getEditLanguage();
01061 }
01062
01063 $sLang = $oLang->getLanguageAbbr( $iLang );
01064
01065 if ( is_null($iShop) ) {
01066 $iShop = $this->getShopId();
01067 }
01068
01069 if ( is_null($sTheme) ) {
01070 $sTheme = $this->getConfigParam( 'sTheme' );
01071 }
01072
01073 if ( $blAdmin ) {
01074 $sTheme = 'admin';
01075 }
01076
01077
01078 $sPath = "$sTheme/$iShop/$sLang/$sDir/$sFile";
01079 $sCacheKey = $sPath . "_$blAbsolute";
01080
01081 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01082 return $sReturn;
01083 }
01084
01085 $sReturn = false;
01086
01087
01088 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01089 $sReturn = $sBase . $sPath;
01090 }
01091
01092
01093 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01094 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01095 $sReturn = $sBase . $sPath;
01096 }
01097
01098
01099
01100 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01101 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01102 $sReturn = $sBase . $sPath;
01103 }
01104
01105
01106 $sPath = "$sTheme/$sDir/$sFile";
01107 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01108 $sReturn = $sBase . $sPath;
01109 }
01110
01111
01112 $sPath = "$sLang/$sDir/$sFile";
01113 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01114 $sReturn = $sBase . $sPath;
01115 }
01116
01117
01118 $sPath = "$sDir/$sFile";
01119 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01120 $sReturn = $sBase . $sPath;
01121 }
01122
01123 if ( !$sReturn ) {
01124
01125 }
01126
01127
01128 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01129
01130 return $sReturn;
01131 }
01132
01147 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01148 {
01149 $sUrl = str_replace(
01150 $this->getOutDir(),
01151 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01152 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01153 );
01154 return $sUrl;
01155 }
01156
01165 public function getImagePath( $sFile, $blAdmin = false )
01166 {
01167 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01168 }
01169
01179 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01180 {
01181 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01182 return $this->getUrl( null, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01183 }
01184
01192 public function getImageDir( $blAdmin = false )
01193 {
01194 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01195 }
01196
01205 public function getPicturePath($sFile, $blAdmin = false )
01206 {
01207 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01208 }
01209
01221 public function getPictureUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null )
01222 {
01223 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01224
01225 if ( $this->isSsl() ) {
01226 $sAltUrl = str_replace( 'http://', 'https://', $sAltUrl );
01227 }
01228
01229 if ( !is_null( $sFile ) ) {
01230 $sAltUrl .= $sFile;
01231 }
01232
01233 return $sAltUrl;
01234 }
01235 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, null, $iLang, $iShopId );
01236 if ( $sFile && $this->getConfigParam('blFormerTplSupport') ) {
01237 $sUrl = str_replace( $this->getPictureUrl( null, $blAdmin, $blSSL, $iLang, $iShopId ), '', $sUrl );
01238 }
01239
01240 if (!$sUrl) {
01241 return $this->getTemplateUrl()."../".$this->_sPictureDir."/0/nopic.jpg";
01242 }
01243 return $sUrl;
01244 }
01245
01253 public function getPictureDir( $blAdmin )
01254 {
01255 return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01256 }
01257
01266 public function getTemplatePath( $sFile, $blAdmin )
01267 {
01268 return $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01269 }
01270
01278 public function getTemplateDir( $blAdmin = false )
01279 {
01280 return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01281 }
01282
01293 public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01294 {
01295 return $this->getUrl( $sFile, $this->_sTemplateDir, $blAdmin, $blSSL, false, $iLang );
01296 }
01297
01305 public function getTemplateBase( $blAdmin = false )
01306 {
01307
01308 return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01309 }
01310
01319 public function getResourcePath($sFile, $blAdmin = false )
01320 {
01321 return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01322 }
01323
01334 public function getResourceUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null )
01335 {
01336 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, false, $iLang );
01337 }
01338
01346 public function getResourceDir( $blAdmin )
01347 {
01348 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01349 }
01350
01360 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01361 {
01362 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01363 }
01364
01372 public function getLanguageDir( $blAdmin )
01373 {
01374 return $this->getDir( null, null, $blAdmin );
01375 }
01376
01384 public function getAbsImageDir()
01385 {
01386 return $this->getImageDir();
01387 }
01388
01399 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01400 {
01401 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
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
01444 }
01445
01455 public function getAbsDynImageDir( $sOverrideShopId = null )
01456 {
01457 return $this->getPictureDir(false);
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472 }
01473
01484 public function getTemplateFile( $sTemplate, $blAdmin = false )
01485 {
01486 return $this->getTemplatePath( $sTemplate, $blAdmin );
01487 }
01488
01498 public function getBaseTemplateDir( $blAdmin = false )
01499 {
01500 return $this->getResourceUrl( null, $blAdmin );
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512 }
01513
01523 public function getBaseTplDir( $blAdmin = false )
01524 {
01525
01526 return $this->getResourceUrl( null, $blAdmin);
01527 }
01528
01536 public function getCurrencyArray( $iCurrency = null )
01537 {
01538 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01539 if ( !is_array( $aConfCurrencies ) ) {
01540 return array();
01541 }
01542
01543 if ( defined( 'OXID_PHP_UNIT' ) ) {
01544 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01545 try{
01546 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01547 if ( isset( $aAltCurrencies ) ) {
01548 $aConfCurrencies = $aAltCurrencies;
01549 }
01550 } catch( Exception $e ) {
01551
01552 }
01553 }
01554 }
01555
01556
01557 $aCurrencies = array();
01558 reset( $aConfCurrencies );
01559 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01560 if ( $val ) {
01561 $oCur = new oxStdClass();
01562 $oCur->id = $key;
01563 $sCur = explode( '@', $val);
01564 $oCur->name = trim( $sCur[0] );
01565 $oCur->rate = trim( $sCur[1] );
01566 $oCur->dec = trim( $sCur[2] );
01567 $oCur->thousand = trim( $sCur[3] );
01568 $oCur->sign = trim( $sCur[4] );
01569 $oCur->decimal = trim( $sCur[5] );
01570
01571
01572 if ( isset( $sCur[6] ) ) {
01573 $oCur->side = trim($sCur[6]);
01574 }
01575
01576 if ( isset( $iCurrency) && $key == $iCurrency ) {
01577 $oCur->selected = 1;
01578 } else {
01579 $oCur->selected = 0;
01580 }
01581 $aCurrencies[$key]= $oCur;
01582 }
01583
01584
01585 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01586 break;
01587 }
01588 }
01589 return $aCurrencies;
01590 }
01591
01599 public function getCurrencyObject( $sName )
01600 {
01601 $aSearch = $this->getCurrencyArray();
01602 foreach ( $aSearch as $oCur ) {
01603 if ( $oCur->name == $sName ) {
01604 return $oCur;
01605 }
01606 }
01607 }
01608
01614 public function isDemoShop()
01615 {
01616 return $this->getConfigParam('blDemoShop');
01617 }
01618
01624 public function getEdition()
01625 {
01626 return "CE";
01627
01628
01629 }
01630
01636 public function getFullEdition()
01637 {
01638 $sEdition = $this->getEdition();
01639
01640 if ($sEdition == "CE") {
01641 return "Community Edition";
01642 }
01643
01644
01645
01646 return $sEdition;
01647 }
01648
01654 public function getVersion()
01655 {
01656 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01657 return $sVersion;
01658 }
01659
01665 public function getRevision()
01666 {
01667 try {
01668 $sFileName = getShopBasePath() . "/pkg.rev";
01669 $iRev = (int) trim(@file_get_contents($sFileName));
01670 } catch (Exception $e) {
01671 return false;
01672 }
01673
01674 if (!$iRev) {
01675 return false;
01676 }
01677
01678 return $iRev;
01679 }
01680
01681
01687 public function isMall()
01688 {
01689
01690 return false;
01691 }
01692
01702 public function detectVersion()
01703 {
01704 }
01705
01706
01707
01718 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01719 {
01720 if ( !$sShopId ) {
01721 $sShopId = $this->getShopId();
01722 }
01723
01724 $oDb = oxDb::getDb();
01725 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01726 $oDb->execute( $sQ );
01727 $sUid = oxUtilsObject::getInstance()->generateUID();
01728
01729 $sUid = mysql_real_escape_string($sUid);
01730 $sShopId = mysql_real_escape_string($sShopId);
01731 $sVarName = mysql_real_escape_string($sVarName);
01732 $sVarVal = mysql_real_escape_string($sVarVal);
01733
01734 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01735 values('$sUid', '$sShopId', '$sVarName', '$sVarType', ENCODE( '$sVarVal', '".$this->getConfigParam('sConfigKey')."'))";
01736
01737 $oDb->execute( $sQ );
01738 }
01739
01748 public function getShopConfVar( $sVarName, $sShopId = null )
01749 {
01750 if ( !$sShopId ) {
01751 $sShopId = $this->getShopId();
01752 }
01753
01754 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01755 $oRs = oxDb::getDb(true)->Execute( $sQ );
01756
01757 $sValue = null;
01758 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01759 $sVarType = $oRs->fields['oxvartype'];
01760 $sVarVal = $oRs->fields['oxvarvalue'];
01761 switch ( $sVarType ) {
01762 case 'arr':
01763 case 'aarr':
01764 $sValue = unserialize( $sVarVal );
01765 break;
01766 case 'bool':
01767 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01768 break;
01769 default:
01770 $sValue = $sVarVal;
01771 }
01772 }
01773 return $sValue;
01774 }
01775
01781 public function isProductiveMode()
01782 {
01783 $blProductive = false;
01784
01785 $blProductive = $this->getConfigParam( 'blProductive' );
01786 if ( !isset( $blProductive ) ) {
01787 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01788 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01789 $this->setConfigParam( 'blProductive', $blProductive );
01790 }
01791
01792 return $blProductive;
01793 }
01794
01795
01796
01802 public function getBaseShopId()
01803 {
01804
01805 return 'oxbaseshop';
01806 }
01807
01813 public function getActiveShop()
01814 {
01815 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01816 $this->_oActShop->getLanguage() == oxLang::getInstance()->getBaseLanguage() ) {
01817 return $this->_oActShop;
01818 }
01819
01820 $this->_oActShop = oxNew( 'oxshop' );
01821 $this->_oActShop->load( $this->getShopId() );
01822 return $this->_oActShop;
01823 }
01824
01830 public function getActiveView()
01831 {
01832 if ( $this->_oActView != null ) {
01833 return $this->_oActView;
01834 }
01835
01836 $this->_oActView = oxNew( 'oxubase' );
01837 return $this->_oActView;
01838 }
01839
01847 public function setActiveView( $oView )
01848 {
01849 $this->_oActView = $oView;
01850 }
01851
01857 public function isUtf()
01858 {
01859 return ( bool ) $this->getConfigParam( 'iUtfMode' );
01860 }
01861 }