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 $_sTemplateDir = 'tpl';
00229
00235 protected $_sResourceDir = 'src';
00236
00242 protected $_blIsSsl = null;
00243
00249 protected $_aAbsDynImageDir = array();
00250
00256 protected $_oActCurrencyObject = null;
00257
00265 public function getConfigParam( $sName )
00266 {
00267 if ( isset( $this->$sName ) ) {
00268 return $this->$sName;
00269 } elseif ( isset ( $this->_aConfigParams[$sName] ) ) {
00270 return $this->_aConfigParams[$sName];
00271 }
00272 }
00273
00282 public function setConfigParam( $sName, $sValue )
00283 {
00284 if ( isset( $this->$sName ) ) {
00285 $this->$sName = $sValue;
00286 } else {
00287 $this->_aConfigParams[$sName] = $sValue;
00288 }
00289 }
00290
00296 public function init()
00297 {
00298 include getShopBasePath().'config.inc.php';
00299 include getShopBasePath().'core/oxconfk.php';
00300
00301
00302 $oFileUtils = oxUtilsFile::getInstance();
00303 $this->sShopDir = $oFileUtils->normalizeDir($this->sShopDir);
00304 $this->sCompileDir = $oFileUtils->normalizeDir($this->sCompileDir);
00305 $this->sShopURL = $oFileUtils->normalizeDir($this->sShopURL);
00306 $this->sSSLShopURL = $oFileUtils->normalizeDir($this->sSSLShopURL);
00307 $this->sAdminSSLURL = $oFileUtils->normalizeDir($this->sAdminSSLURL);
00308
00309
00310
00311 if( !$this->getConfigParam( 'sDefaultLang' ) )
00312 $this->setConfigParam( 'sDefaultLang', 0 );
00313
00314 $blLogChangesInAdmin = $this->getConfigParam( 'blLogChangesInAdmin' );
00315 if( !isset( $blLogChangesInAdmin ) )
00316 $this->setConfigParam( 'blLogChangesInAdmin', false );
00317
00318 $blCheckTemplates = $this->getConfigParam( 'blCheckTemplates' );
00319 if( !isset( $blCheckTemplates ) )
00320 $this->setConfigParam( 'blCheckTemplates', false );
00321
00322 $blAllowArticlesubclass = $this->getConfigParam( 'blAllowArticlesubclass' );
00323 if( !isset( $blAllowArticlesubclass ) )
00324 $this->setConfigParam( 'blAllowArticlesubclass', false );
00325
00326 $iAdminListSize = $this->getConfigParam( 'iAdminListSize' );
00327 if( !isset( $iAdminListSize ) )
00328 $this->setConfigParam( 'iAdminListSize', 9 );
00329
00330
00331 $iPicCount = $this->getConfigParam( 'iPicCount' );
00332 if( !isset( $iPicCount ) )
00333 $this->setConfigParam( 'iPicCount', 12 );
00334
00335 $iZoomPicCount = $this->getConfigParam( 'iZoomPicCount' );
00336 if( !isset( $iZoomPicCount ) )
00337 $this->setConfigParam( 'iZoomPicCount', 4 );
00338
00339
00340 $iMaxShopId = $this->getConfigParam( 'iMaxShopId' );
00341 if( !isset( $iMaxShopId ) )
00342 $this->setConfigParam( 'iMaxShopId', 64 );
00343
00344
00345 $this->setConfigParam( 'blTemplateCaching', false );
00346
00347
00348 global $ADODB_SESS_LIFE;
00349 $ADODB_SESS_LIFE = 1;
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 $iDBCacheLifeTime = $this->getConfigParam( 'iDBCacheLifeTime' );
00363 if( !isset( $iDBCacheLifeTime ) )
00364 $this->setConfigParam( 'iDBCacheLifeTime', 3600 );
00365
00366 $sCoreDir = $this->getConfigParam( 'sShopDir' );
00367 $this->setConfigParam( 'sCoreDir', $sCoreDir.'/core/' );
00368
00369 try {
00370
00371 $this->getSession()->start();
00372
00373 $sShopID = $this->getShopId();
00374
00375
00376 $this->_loadVarsFromDb( $sShopID );
00377
00378 } catch ( oxConnectionException $oEx ) {
00379 $oEx->debugOut( $this->iDebug);
00380 if ( defined( 'OXID_PHP_UNIT' ) ) {
00381 return false;
00382 } elseif ( 0 != $this->iDebug ) {
00383 exit( $oEx->getString() );
00384 } else {
00385 header( "HTTP/1.1 500 Internal Server Error");
00386 header( "Location: offline.html");
00387 header( "Connection: close");
00388 }
00389 } catch ( oxCookieException $oEx ) {
00390
00391 oxUtilsView::getInstance()->addErrorToDisplay( $oEx );
00392 oxUtils::getInstance()->redirect( $this->getShopHomeURL() .'cl=start' );
00393 }
00394
00395
00396 $this->_oStart = new oxStart();
00397 $this->_oStart->appInit();
00398 }
00399
00405 public static function getInstance()
00406 {
00407
00408 if ( defined( 'OXID_PHP_UNIT' ) ) {
00409 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00410 return modConfig::$unitMOD;
00411 }
00412 }
00413
00414 if ( !self::$_instance instanceof oxConfig ) {
00415
00416
00417 self::$_instance = new oxConfig();
00418 self::$_instance->init();
00419 }
00420 return self::$_instance;
00421 }
00422
00431 protected function _loadVarsFromDb( $sShopID, $aOnlyVars = null )
00432 {
00433
00434 $sQ = "select oxvarname, oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopID'";
00435
00436 if ( $aOnlyVars !== null ) {
00437 $blSep = false;
00438 $sIn = '';
00439 foreach ( $aOnlyVars as $sField ) {
00440 if ( $blSep ) {
00441 $sIn .= ', ';
00442 }
00443 $sIn .= '"'.$sField.'"';
00444 $blSep = true;
00445 }
00446 $sQ .= ' and oxvarname in ( '.$sIn.' ) ';
00447 }
00448
00449 $oRs = oxDb::getDb()->execute( $sQ );
00450 if ( $oRs != false && $oRs->recordCount() > 0 ) {
00451 while ( !$oRs->EOF ) {
00452 $sVarName = $oRs->fields[0];
00453 $sVarType = $oRs->fields[1];
00454 $sVarVal = $oRs->fields[2];
00455
00456
00457 if ( ( $sVarName == 'sShopURL' || $sVarName == 'sSSLShopURL' ) &&
00458 ( !$sVarVal || $this->isAdmin() === true ) ) {
00459 $oRs->moveNext();
00460 continue;
00461 }
00462
00463 switch ( $sVarType ) {
00464 case 'arr':
00465 case 'aarr':
00466 $this->setConfigParam( $sVarName, unserialize( $sVarVal ) );
00467 break;
00468 case 'bool':
00469 $this->setConfigParam( $sVarName, ( $sVarVal == 'true' || $sVarVal == '1' ) );
00470 break;
00471 default:
00472 $this->setConfigParam( $sVarName, $sVarVal );
00473 break;
00474 }
00475
00476 $oRs->moveNext();
00477 }
00478 }
00479
00480 }
00481
00487 public function pageClose()
00488 {
00489 return $this->_oStart->pageClose();
00490 }
00491
00505 public static function getParameter( $sName, $blRaw = false )
00506 {
00507 if ( defined( 'OXID_PHP_UNIT' ) ) {
00508 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00509 try{
00510 return modConfig::getParameter( $sName, $blRaw );
00511 } catch( Exception $e ) {
00512
00513 }
00514 }
00515 }
00516
00517 $sValue = null;
00518 if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST[$sName] ) ) {
00519 $sValue = $_POST[$sName];
00520 } elseif ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] == 'GET' && isset( $_GET[$sName] ) ) {
00521 $sValue = $_GET[$sName];
00522
00523 } elseif ( oxSession::hasVar( $sName ) ) {
00524 $sValue = oxSession::getVar( $sName );
00525
00526 } else {
00527 $sValue = null;
00528 }
00529
00530
00531 $blIsAdmin = oxConfig::getInstance()->isAdmin() && oxSession::getVar("blIsAdmin");
00532 if ( $sValue != null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00533 self::checkSpecialChars( $sValue, $blRaw );
00534 }
00535
00536 return $sValue;
00537 }
00538
00546 public function getUploadedFile($sParamName)
00547 {
00548 return $_FILES[$sParamName];
00549 }
00550
00559 public function setGlobalParameter( $sName, $sValue )
00560 {
00561 $this->_aGlobalParams[$sName] = $sValue;
00562 }
00563
00571 public function getGlobalParameter( $sName )
00572 {
00573 if ( isset( $this->_aGlobalParams[$sName] ) ) {
00574 return $this->_aGlobalParams[$sName];
00575 } else {
00576 return null;
00577 }
00578 }
00579
00589 public static function checkSpecialChars( & $sValue, $aRaw = null )
00590 {
00591 if ( is_object( $sValue ) ) {
00592 return $sValue;
00593 }
00594
00595 if ( is_array( $sValue ) ) {
00596 $newValue = array();
00597 foreach ( $sValue as $sKey => $sVal ) {
00598 $sValidKey = $sKey;
00599 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00600 self::checkSpecialChars( $sValidKey );
00601 self::checkSpecialChars( $sVal );
00602 if ($sValidKey != $sKey) {
00603 unset ($sValue[$sKey]);
00604 }
00605 }
00606 $newValue[$sValidKey] = $sVal;
00607 }
00608 $sValue = $newValue;
00609 } else {
00610 $sValue = str_replace( array( '&', '<', '>', '"', "'", chr(0), '\\' ),
00611 array( '&', '<', '>', '"', ''', '', '\' ),
00612 $sValue );
00613 }
00614 return $sValue;
00615 }
00616
00622 public function getShopId()
00623 {
00624 if ( $this->_iShopId !== null )
00625 return $this->_iShopId;
00626
00627 $this->_iShopId = $this->getBaseShopId();
00628
00629
00630 oxSession::setVar( 'actshop', $this->_iShopId );
00631 return $this->_iShopId;
00632 }
00633
00641 public function setShopId( $sShopId )
00642 {
00643 oxSession::setVar( 'actshop', $sShopId );
00644 $this->_iShopId = $sShopId;
00645 }
00646
00647
00653 public function isSsl()
00654 {
00655 if ( is_null( $this->_blIsSsl ) ) {
00656
00657 $myUtilsServer = oxUtilsServer::getInstance();
00658 $aServerVars = $myUtilsServer->getServerVar();
00659 $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00660
00661 $this->_blIsSsl = ( isset( $aHttpsServerVar ) && $this->getConfigParam( 'sSSLShopURL' ) &&
00662 ( $aHttpsServerVar == 'on' || $aHttpsServerVar == '1' ) );
00663
00664
00665 if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00666 ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00667 strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00668 $this->_blIsSsl = true;
00669 }
00670 }
00671
00672 return $this->_blIsSsl;
00673 }
00674
00682 public function isCurrentUrl( $sURL )
00683 {
00684 if ( !$sURL ) {
00685 return false;
00686 }
00687
00688 $sCurrentHost = preg_replace( '/\/\w*\.php.*/', '', $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'] );
00689
00690
00691 $sCurrentHost = str_replace( '/', '', $sCurrentHost );
00692 $sURL = str_replace( '/', '', $sURL );
00693
00694
00695 if ( getStr()->strpos( $sURL, $sCurrentHost ) !== false ) {
00696 return true;
00697 }
00698
00699 return false;
00700 }
00701
00710 public function getShopUrl( $iLang = null, $blAdmin = null )
00711 {
00712 $blAdmin = isset( $blAdmin ) ? $blAdmin : $this->isAdmin();
00713 if ( $blAdmin ) {
00714 return $this->getConfigParam( 'sShopURL' );
00715 }
00716
00717
00718 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00719 $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00720 if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) && !empty( $aLanguageURLs[$iLang] ) ) {
00721 $aLanguageURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageURLs[$iLang] );
00722 return $aLanguageURLs[$iLang];
00723 }
00724
00725
00726 $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00727 if ( $sMallShopURL ) {
00728 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00729 return $sMallShopURL;
00730 }
00731
00732 return $this->getConfigParam( 'sShopURL' );
00733 }
00734
00742 public function getSslShopUrl( $iLang = null )
00743 {
00744
00745 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00746 $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
00747 if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) && !empty( $aLanguageSSLURLs[$iLang] ) ) {
00748 $aLanguageSSLURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageSSLURLs[$iLang] );
00749 return $aLanguageSSLURLs[$iLang];
00750 }
00751
00752
00753 if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
00754 $sMallSSLShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallSSLShopURL );
00755 return $sMallSSLShopURL;
00756 }
00757
00758 if ( ( $sMallShopURL = $this->getConfigParam( 'sMallShopURL' ) ) ) {
00759 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00760 return $sMallShopURL;
00761 }
00762
00763
00764 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00765 return $sSSLShopURL;
00766 }
00767
00768 return $this->getShopUrl( $iLang );
00769 }
00770
00776 public function getCoreUtilsUrl()
00777 {
00778 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00779 return $sSSLShopURL.'core/utils/';
00780 }
00781 return $this->getConfigParam( 'sShopURL' ).'core/utils/';
00782 }
00783
00789 public function getCurrentShopUrl()
00790 {
00791 if ( $this->isSsl() ) {
00792 return $this->getSslShopUrl();
00793 }
00794 return $this->getShopUrl();
00795 }
00796
00804 public function getShopCurrentUrl( $iLang = null )
00805 {
00806 if ( $this->isSsl() ) {
00807 $sURL = $this->getSSLShopURL( $iLang );
00808 } else {
00809 $sURL = $this->getShopURL( $iLang );
00810 }
00811
00812 return $this->getSession()->url( $sURL.'index.php' );
00813 }
00814
00823 public function getShopHomeUrl( $iLang = null, $blAdmin = null )
00824 {
00825 return $this->getSession()->url( $this->getShopUrl( $iLang, $blAdmin).'index.php' );
00826 }
00827
00833 public function getShopSecureHomeUrl()
00834 {
00835 return $this->getSession()->url( $this->getSslShopUrl().'index.php' );
00836 }
00837
00843 public function getShopCurrency()
00844 {
00845 return (int) oxConfig::getParameter( 'currency' );
00846 }
00847
00853 public function getActShopCurrencyObject()
00854 {
00855
00856
00857 if ( !defined( 'OXID_PHP_UNIT' ) ) {
00858 if (!is_null($this->_oActCurrencyObject)) {
00859 return $this->_oActCurrencyObject;
00860 }
00861 }
00862
00863 $iCur = oxConfig::getParameter( 'cur' );
00864 if ( !isset( $iCur ) ) {
00865 $iCur = $this->getShopCurrency();
00866 }
00867
00868 $aCurrencies = $this->getCurrencyArray();
00869 if ( !isset( $aCurrencies[$iCur] ) ) {
00870 return $this->_oActCurrencyObject = reset( $aCurrencies );
00871 }
00872
00873 return $this->_oActCurrencyObject = $aCurrencies[$iCur];
00874 }
00875
00883 public function setActShopCurrency( $iCur )
00884 {
00885 $aCurrencies = $this->getCurrencyArray();
00886 if ( isset( $aCurrencies[$iCur] ) ) {
00887 oxSession::setVar( 'currency', $iCur );
00888 $this->_oActCurrencyObject = null;
00889 }
00890 }
00891
00892
00902 public function getNoSslImageDir( $blAdmin = false )
00903 {
00904 return $this->getImageUrl( $blAdmin, false );
00905 }
00906
00914 public function getAbsAdminImageDir()
00915 {
00916 return $this->getImageDir( true );
00917
00918 }
00919
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00994 public function getOutDir( $blAbsolute = true)
00995 {
00996 if ($blAbsolute) {
00997 return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
00998 } else {
00999 return $this->_sOutDir.'/';
01000 }
01001 }
01002
01012 public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01013 {
01014 $blSSL = is_null($blSSL)?$this->isSsl():$blSSL;
01015 $blAdmin = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01016
01017 if ( $blSSL ) {
01018 $sUrl = ($blNativeImg && !$blAdmin )?$this->getSslShopUrl():$this->getConfigParam( 'sSSLShopURL');
01019 } else {
01020 $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01021 }
01022
01023 return $sUrl.$this->_sOutDir.'/';
01024 }
01025
01039 public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true )
01040 {
01041 $sBase = $this->getOutDir( $blAbsolute );
01042 $sAbsBase = $this->getOutDir();
01043
01044 $oLang = oxLang::getInstance();
01045
01046 if ( is_null($iLang) ) {
01047 $iLang = $oLang->getEditLanguage();
01048 }
01049
01050 $sLang = $oLang->getLanguageAbbr( $iLang );
01051
01052 if ( is_null($iShop) ) {
01053 $iShop = $this->getShopId();
01054 }
01055
01056 if ( is_null($sTheme) ) {
01057 $sTheme = $this->getConfigParam( 'sTheme' );
01058 }
01059
01060 if ( $blAdmin ) {
01061 $sTheme = 'admin';
01062 }
01063
01064
01065 $sPath = "$sTheme/$iShop/$sLang/$sDir/$sFile";
01066 $sCacheKey = $sPath . "_$blAbsolute";
01067
01068 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01069 return $sReturn;
01070 }
01071
01072 $sReturn = false;
01073
01074
01075 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01076 $sReturn = $sBase . $sPath;
01077 }
01078
01079
01080 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01081 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01082 $sReturn = $sBase . $sPath;
01083 }
01084
01085
01086
01087 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01088 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01089 $sReturn = $sBase . $sPath;
01090 }
01091
01092
01093 $sPath = "$sTheme/$sDir/$sFile";
01094 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01095 $sReturn = $sBase . $sPath;
01096 }
01097
01098
01099 $sPath = "$sLang/$sDir/$sFile";
01100 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01101 $sReturn = $sBase . $sPath;
01102 }
01103
01104
01105 $sPath = "$sDir/$sFile";
01106 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01107 $sReturn = $sBase . $sPath;
01108 }
01109
01110 if ( !$sReturn ) {
01111
01112 }
01113
01114
01115 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01116
01117 return $sReturn;
01118 }
01119
01134 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01135 {
01136 $sUrl = str_replace(
01137 $this->getOutDir(),
01138 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01139 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01140 );
01141 return $sUrl;
01142 }
01143
01152 public function getImagePath( $sFile, $blAdmin = false )
01153 {
01154 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01155 }
01156
01166 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01167 {
01168 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01169 return $this->getUrl( null, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01170 }
01171
01179 public function getImageDir( $blAdmin = false )
01180 {
01181 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01182 }
01183
01192 public function getPicturePath($sFile, $blAdmin = false )
01193 {
01194 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01195 }
01196
01208 public function getPictureUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null )
01209 {
01210 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01211
01212 if ( $this->isSsl() ) {
01213 $sAltUrl = str_replace( 'http://', 'https://', $sAltUrl );
01214 }
01215
01216 if ( !is_null( $sFile ) ) {
01217 $sAltUrl .= $sFile;
01218 }
01219
01220 return $sAltUrl;
01221 }
01222 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, null, $iLang, $iShopId );
01223 if ( $sFile && $this->getConfigParam('blFormerTplSupport') ) {
01224 $sUrl = str_replace( $this->getPictureUrl( null, $blAdmin, $blSSL, $iLang, $iShopId ), '', $sUrl );
01225 }
01226
01227 if (!$sUrl) {
01228 return $this->getTemplateUrl()."../".$this->_sPictureDir."/0/nopic.jpg";
01229 }
01230 return $sUrl;
01231 }
01232
01240 public function getPictureDir( $blAdmin )
01241 {
01242 return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01243 }
01244
01253 public function getTemplatePath( $sFile, $blAdmin )
01254 {
01255 return $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01256 }
01257
01265 public function getTemplateDir( $blAdmin = false )
01266 {
01267 return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01268 }
01269
01280 public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01281 {
01282 return $this->getUrl( $sFile, $this->_sTemplateDir, $blAdmin, $blSSL, false, $iLang );
01283 }
01284
01292 public function getTemplateBase( $blAdmin = false )
01293 {
01294
01295 return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01296 }
01297
01306 public function getResourcePath($sFile, $blAdmin = false )
01307 {
01308 return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01309 }
01310
01321 public function getResourceUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null )
01322 {
01323 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, false, $iLang );
01324 }
01325
01333 public function getResourceDir( $blAdmin )
01334 {
01335 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01336 }
01337
01347 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01348 {
01349 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01350 }
01351
01359 public function getLanguageDir( $blAdmin )
01360 {
01361 return $this->getDir( null, null, $blAdmin );
01362 }
01363
01371 public function getAbsImageDir()
01372 {
01373 return $this->getImageDir();
01374 }
01375
01386 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01387 {
01388 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
01389
01390
01391
01392
01393
01394
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
01442 public function getAbsDynImageDir( $sOverrideShopId = null )
01443 {
01444 return $this->getPictureDir(false);
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459 }
01460
01471 public function getTemplateFile( $sTemplate, $blAdmin = false )
01472 {
01473 return $this->getTemplatePath( $sTemplate, $blAdmin );
01474 }
01475
01485 public function getBaseTemplateDir( $blAdmin = false )
01486 {
01487 return $this->getResourceUrl( null, $blAdmin );
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499 }
01500
01510 public function getBaseTplDir( $blAdmin = false )
01511 {
01512
01513 return $this->getResourceUrl( null, $blAdmin);
01514 }
01515
01523 public function getCurrencyArray( $iCurrency = null )
01524 {
01525 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01526 if ( !is_array( $aConfCurrencies ) ) {
01527 return array();
01528 }
01529
01530 if ( defined( 'OXID_PHP_UNIT' ) ) {
01531 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01532 try{
01533 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01534 if ( isset( $aAltCurrencies ) ) {
01535 $aConfCurrencies = $aAltCurrencies;
01536 }
01537 } catch( Exception $e ) {
01538
01539 }
01540 }
01541 }
01542
01543
01544 $aCurrencies = array();
01545 reset( $aConfCurrencies );
01546 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01547 if ( $val ) {
01548 $oCur = new oxStdClass();
01549 $oCur->id = $key;
01550 $sCur = explode( '@', $val);
01551 $oCur->name = trim( $sCur[0] );
01552 $oCur->rate = trim( $sCur[1] );
01553 $oCur->dec = trim( $sCur[2] );
01554 $oCur->thousand = trim( $sCur[3] );
01555 $oCur->sign = trim( $sCur[4] );
01556 $oCur->decimal = trim( $sCur[5] );
01557
01558
01559 if ( isset( $sCur[6] ) ) {
01560 $oCur->side = trim($sCur[6]);
01561 }
01562
01563 if ( isset( $iCurrency) && $key == $iCurrency ) {
01564 $oCur->selected = 1;
01565 } else {
01566 $oCur->selected = 0;
01567 }
01568 $aCurrencies[$key]= $oCur;
01569 }
01570
01571
01572 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01573 break;
01574 }
01575 }
01576 return $aCurrencies;
01577 }
01578
01586 public function getCurrencyObject( $sName )
01587 {
01588 $aSearch = $this->getCurrencyArray();
01589 foreach ( $aSearch as $oCur ) {
01590 if ( $oCur->name == $sName ) {
01591 return $oCur;
01592 }
01593 }
01594 }
01595
01601 public function isDemoShop()
01602 {
01603 return $this->getConfigParam('blDemoShop');
01604 }
01605
01611 public function getEdition()
01612 {
01613 return "CE";
01614
01615
01616 }
01617
01623 public function getFullEdition()
01624 {
01625 $sEdition = $this->getEdition();
01626
01627 if ($sEdition == "CE") {
01628 return "Community Edition";
01629 }
01630
01631
01632
01633 return $sEdition;
01634 }
01635
01641 public function getVersion()
01642 {
01643 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01644 return $sVersion;
01645 }
01646
01652 public function getRevision()
01653 {
01654 try {
01655 $sFileName = getShopBasePath() . "/pkg.rev";
01656 $iRev = (int) trim(@file_get_contents($sFileName));
01657 } catch (Exception $e) {
01658 return false;
01659 }
01660
01661 if (!$iRev) {
01662 return false;
01663 }
01664
01665 return $iRev;
01666 }
01667
01668
01674 public function isMall()
01675 {
01676
01677 return false;
01678 }
01679
01689 public function detectVersion()
01690 {
01691 }
01692
01693
01694
01705 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01706 {
01707 if ( !$sShopId ) {
01708 $sShopId = $this->getShopId();
01709 }
01710
01711 $oDb = oxDb::getDb();
01712 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01713 $oDb->execute( $sQ );
01714 $sUid = oxUtilsObject::getInstance()->generateUID();
01715
01716 $sUid = mysql_real_escape_string($sUid);
01717 $sShopId = mysql_real_escape_string($sShopId);
01718 $sVarName = mysql_real_escape_string($sVarName);
01719 $sVarVal = mysql_real_escape_string($sVarVal);
01720
01721 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01722 values('$sUid', '$sShopId', '$sVarName', '$sVarType', ENCODE( '$sVarVal', '".$this->getConfigParam('sConfigKey')."'))";
01723
01724 $oDb->execute( $sQ );
01725 }
01726
01735 public function getShopConfVar( $sVarName, $sShopId = null )
01736 {
01737 if ( !$sShopId ) {
01738 $sShopId = $this->getShopId();
01739 }
01740
01741 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01742 $oRs = oxDb::getDb(true)->Execute( $sQ );
01743
01744 $sValue = null;
01745 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01746 $sVarType = $oRs->fields['oxvartype'];
01747 $sVarVal = $oRs->fields['oxvarvalue'];
01748 switch ( $sVarType ) {
01749 case 'arr':
01750 case 'aarr':
01751 $sValue = unserialize( $sVarVal );
01752 break;
01753 case 'bool':
01754 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01755 break;
01756 default:
01757 $sValue = $sVarVal;
01758 break;
01759 }
01760 }
01761 return $sValue;
01762 }
01763
01769 public function isProductiveMode()
01770 {
01771 $blProductive = false;
01772
01773 $blProductive = $this->getConfigParam( 'blProductive' );
01774 if ( !isset( $blProductive ) ) {
01775 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01776 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01777 $this->setConfigParam( 'blProductive', $blProductive );
01778 }
01779
01780 return $blProductive;
01781 }
01782
01783
01784
01790 public function getBaseShopId()
01791 {
01792
01793 return 'oxbaseshop';
01794 }
01795
01801 public function getActiveShop()
01802 {
01803 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01804 $this->_oActShop->getLanguage() == oxLang::getInstance()->getBaseLanguage() ) {
01805 return $this->_oActShop;
01806 }
01807
01808 $this->_oActShop = oxNew( 'oxshop' );
01809 $this->_oActShop->load( $this->getShopId() );
01810 return $this->_oActShop;
01811 }
01812
01818 public function getActiveView()
01819 {
01820 if ( $this->_oActView != null ) {
01821 return $this->_oActView;
01822 }
01823
01824 $this->_oActView = oxNew( 'oxubase' );
01825 return $this->_oActView;
01826 }
01827
01835 public function setActiveView( $oView )
01836 {
01837 $this->_oActView = $oView;
01838 }
01839
01845 public function isUtf()
01846 {
01847 return ( bool ) $this->getConfigParam( 'iUtfMode' );
01848 }
01849 }