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', true, 302 );
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
00634
00642 public function setShopId( $sShopId )
00643 {
00644 oxSession::setVar( 'actshop', $sShopId );
00645 $this->_iShopId = $sShopId;
00646 }
00647
00648
00654 public function isSsl()
00655 {
00656 if ( is_null( $this->_blIsSsl ) ) {
00657
00658 $myUtilsServer = oxUtilsServer::getInstance();
00659 $aServerVars = $myUtilsServer->getServerVar();
00660 $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00661
00662 $this->_blIsSsl = ( isset( $aHttpsServerVar ) && ( $this->getConfigParam( 'sSSLShopURL' ) || $this->getConfigParam( 'sMallSSLShopURL' ) ) &&
00663 ( $aHttpsServerVar === 'on' || $aHttpsServerVar == '1' ) );
00664
00665
00666 if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00667 ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00668 strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00669 $this->_blIsSsl = true;
00670 }
00671 }
00672
00673 return $this->_blIsSsl;
00674 }
00675
00683 public function isCurrentUrl( $sURL )
00684 {
00685 if ( !$sURL ) {
00686 return false;
00687 }
00688
00689 $oUtilsServer = oxUtilsServer::getInstance();
00690 $sHost = $oUtilsServer->getServerVar( 'HTTP_HOST' );
00691 $sScriptName = $oUtilsServer->getServerVar( 'SCRIPT_NAME' );
00692
00693 $sCurrentHost = preg_replace( '/\/\w*\.php.*/', '', $sHost . $sScriptName );
00694
00695
00696 $sCurrentHost = str_replace( '/', '', $sCurrentHost );
00697 $sURL = str_replace( '/', '', $sURL );
00698
00699
00700 if ( getStr()->strpos( $sURL, $sCurrentHost ) !== false ) {
00701 return true;
00702 }
00703
00704 return false;
00705 }
00706
00715 public function getShopUrl( $iLang = null, $blAdmin = null )
00716 {
00717 $blAdmin = isset( $blAdmin ) ? $blAdmin : $this->isAdmin();
00718 if ( $blAdmin ) {
00719 return $this->getConfigParam( 'sShopURL' );
00720 }
00721
00722
00723 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00724 $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00725 if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) && !empty( $aLanguageURLs[$iLang] ) ) {
00726 $aLanguageURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageURLs[$iLang] );
00727 return $aLanguageURLs[$iLang];
00728 }
00729
00730
00731 $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00732 if ( $sMallShopURL ) {
00733 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00734 return $sMallShopURL;
00735 }
00736
00737 return $this->getConfigParam( 'sShopURL' );
00738 }
00739
00747 public function getSslShopUrl( $iLang = null )
00748 {
00749
00750 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00751 $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
00752 if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) && !empty( $aLanguageSSLURLs[$iLang] ) ) {
00753 $aLanguageSSLURLs[$iLang] = oxUtils::getInstance()->checkUrlEndingSlash( $aLanguageSSLURLs[$iLang] );
00754 return $aLanguageSSLURLs[$iLang];
00755 }
00756
00757
00758 if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
00759 $sMallSSLShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallSSLShopURL );
00760 return $sMallSSLShopURL;
00761 }
00762
00763 if ( ( $sMallShopURL = $this->getConfigParam( 'sMallShopURL' ) ) ) {
00764 $sMallShopURL = oxUtils::getInstance()->checkUrlEndingSlash( $sMallShopURL );
00765 return $sMallShopURL;
00766 }
00767
00768
00769 if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00770 return $sSSLShopURL;
00771 }
00772
00773 return $this->getShopUrl( $iLang );
00774 }
00775
00781 public function getCoreUtilsUrl()
00782 {
00783 return $this->getCurrentShopUrl().'core/utils/';
00784 }
00785
00791 public function getCurrentShopUrl()
00792 {
00793 if ( $this->isSsl() ) {
00794 return $this->getSslShopUrl();
00795 }
00796 return $this->getShopUrl();
00797 }
00798
00806 public function getShopCurrentUrl( $iLang = null )
00807 {
00808 if ( $this->isSsl() ) {
00809 $sURL = $this->getSSLShopURL( $iLang );
00810 } else {
00811 $sURL = $this->getShopURL( $iLang );
00812 }
00813
00814 return $this->getSession()->url( $sURL.'index.php' );
00815 }
00816
00825 public function getShopHomeUrl( $iLang = null, $blAdmin = null )
00826 {
00827 return $this->getSession()->url( $this->getShopUrl( $iLang, $blAdmin).'index.php' );
00828 }
00829
00835 public function getShopSecureHomeUrl()
00836 {
00837 return $this->getSession()->url( $this->getSslShopUrl().'index.php' );
00838 }
00839
00845 public function getShopCurrency()
00846 {
00847 return (int) oxConfig::getParameter( 'currency' );
00848 }
00849
00855 public function getActShopCurrencyObject()
00856 {
00857
00858
00859 if ( !defined( 'OXID_PHP_UNIT' ) ) {
00860 if (!is_null($this->_oActCurrencyObject)) {
00861 return $this->_oActCurrencyObject;
00862 }
00863 }
00864
00865 $iCur = oxConfig::getParameter( 'cur' );
00866 if ( !isset( $iCur ) ) {
00867 $iCur = $this->getShopCurrency();
00868 }
00869
00870 $aCurrencies = $this->getCurrencyArray();
00871 if ( !isset( $aCurrencies[$iCur] ) ) {
00872 return $this->_oActCurrencyObject = reset( $aCurrencies );
00873 }
00874
00875 return $this->_oActCurrencyObject = $aCurrencies[$iCur];
00876 }
00877
00885 public function setActShopCurrency( $iCur )
00886 {
00887 $aCurrencies = $this->getCurrencyArray();
00888 if ( isset( $aCurrencies[$iCur] ) ) {
00889 oxSession::setVar( 'currency', $iCur );
00890 $this->_oActCurrencyObject = null;
00891 }
00892 }
00893
00894
00904 public function getNoSslImageDir( $blAdmin = false )
00905 {
00906 return $this->getImageUrl( $blAdmin, false );
00907 }
00908
00916 public function getAbsAdminImageDir()
00917 {
00918 return $this->getImageDir( true );
00919
00920 }
00921
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
00987
00988
00996 public function getOutDir( $blAbsolute = true)
00997 {
00998 if ($blAbsolute) {
00999 return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01000 } else {
01001 return $this->_sOutDir.'/';
01002 }
01003 }
01004
01014 public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01015 {
01016 $blSSL = is_null($blSSL)?$this->isSsl():$blSSL;
01017 $blAdmin = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01018
01019 if ( $blSSL ) {
01020 $sUrl = ($blNativeImg && !$blAdmin )?$this->getSslShopUrl():$this->getConfigParam( 'sSSLShopURL');
01021 } else {
01022 $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01023 }
01024
01025 return $sUrl.$this->_sOutDir.'/';
01026 }
01027
01041 public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true )
01042 {
01043 if ( is_null($sTheme) ) {
01044 $sTheme = $this->getConfigParam( 'sTheme' );
01045 }
01046
01047 if ( $blAdmin ) {
01048 $sTheme = 'admin';
01049 }
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
01067 $sPath = "$sTheme/$iShop/$sLang/$sDir/$sFile";
01068 $sCacheKey = $sPath . "_$blAbsolute";
01069
01070 if ( ( $sReturn = oxutils::getInstance()->fromStaticCache( $sCacheKey ) ) !== null ) {
01071 return $sReturn;
01072 }
01073
01074 $sReturn = false;
01075
01076
01077 $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
01078 if( !$blAdmin && $sCustomTheme && $sCustomTheme != $sTheme) {
01079 $sReturn = $this->getDir($sFile, $sDir, $blAdmin, $iLang, $iShopl, $sCustomTheme, $blAbsolute, $blReturnArray);
01080 }
01081
01082
01083 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01084 $sReturn = $sBase . $sPath;
01085 }
01086
01087
01088 $sPath = "$sTheme/$iShop/$sDir/$sFile";
01089 if ( !$sReturn && !$blAdmin && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath ) ) ) ) {
01090 $sReturn = $sBase . $sPath;
01091 }
01092
01093
01094
01095 $sPath = "$sTheme/$sLang/$sDir/$sFile";
01096 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01097 $sReturn = $sBase . $sPath;
01098 }
01099
01100
01101 $sPath = "$sTheme/$sDir/$sFile";
01102 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01103 $sReturn = $sBase . $sPath;
01104 }
01105
01106
01107 $sPath = "$sLang/$sDir/$sFile";
01108 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01109 $sReturn = $sBase . $sPath;
01110 }
01111
01112
01113 $sPath = "$sDir/$sFile";
01114 if ( !$sReturn && ( is_readable( $sAbsBase.$sPath ) || is_dir( realpath( $sAbsBase.$sPath )) ) ) {
01115 $sReturn = $sBase . $sPath;
01116 }
01117
01118 if ( !$sReturn ) {
01119
01120 }
01121
01122
01123 oxutils::getInstance()->toStaticCache( $sCacheKey, $sReturn );
01124
01125 return $sReturn;
01126 }
01127
01142 public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01143 {
01144 $sUrl = str_replace(
01145 $this->getOutDir(),
01146 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01147 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01148 );
01149 return $sUrl;
01150 }
01151
01160 public function getImagePath( $sFile, $blAdmin = false )
01161 {
01162 return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01163 }
01164
01174 public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null )
01175 {
01176 $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01177 return $this->getUrl( null, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01178 }
01179
01187 public function getImageDir( $blAdmin = false )
01188 {
01189 return $this->getDir( null, $this->_sImageDir, $blAdmin );
01190 }
01191
01200 public function getPicturePath($sFile, $blAdmin = false )
01201 {
01202 return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin );
01203 }
01204
01216 public function getPictureUrl( $sFile, $blAdmin = false , $blSSL = null , $iLang = null, $iShopId = null )
01217 {
01218 if ( $sAltUrl = $this->getConfigParam( 'sAltImageDir' ) ) {
01219
01220 if ( $this->isSsl() ) {
01221 $sAltUrl = str_replace( 'http://', 'https://', $sAltUrl );
01222 }
01223
01224 if ( !is_null( $sFile ) ) {
01225 $sAltUrl .= $sFile;
01226 }
01227
01228 return $sAltUrl;
01229 }
01230
01231 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01232
01233 $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $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 $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01335 return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, $blNativeImg, $iLang );
01336 }
01337
01345 public function getResourceDir( $blAdmin )
01346 {
01347 return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01348 }
01349
01359 public function getLanguagePath( $sFile, $blAdmin, $iLang = null )
01360 {
01361 return $this->getDir( $sFile, oxLang::getInstance()->getLanguageAbbr( $iLang ), $blAdmin, $iLang );
01362 }
01363
01371 public function getLanguageDir( $blAdmin )
01372 {
01373 return $this->getDir( null, null, $blAdmin );
01374 }
01375
01383 public function getAbsImageDir()
01384 {
01385 return $this->getImageDir();
01386 }
01387
01398 public function getDynImageDir( $sOverrideShopId = null, $blNoSsl = null )
01399 {
01400 return $this->getPictureUrl(null, false, $this->isSsl() && !$blNoSsl, null, $sOverrideShopId);
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 }
01444
01454 public function getAbsDynImageDir( $sOverrideShopId = null )
01455 {
01456 return $this->getPictureDir(false);
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471 }
01472
01483 public function getTemplateFile( $sTemplate, $blAdmin = false )
01484 {
01485 return $this->getTemplatePath( $sTemplate, $blAdmin );
01486 }
01487
01497 public function getBaseTemplateDir( $blAdmin = false )
01498 {
01499 return $this->getResourceUrl( null, $blAdmin );
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511 }
01512
01522 public function getBaseTplDir( $blAdmin = false )
01523 {
01524
01525 return $this->getResourceUrl( null, $blAdmin);
01526 }
01527
01535 public function getCurrencyArray( $iCurrency = null )
01536 {
01537 $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01538 if ( !is_array( $aConfCurrencies ) ) {
01539 return array();
01540 }
01541
01542 if ( defined( 'OXID_PHP_UNIT' ) ) {
01543 if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01544 try{
01545 $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01546 if ( isset( $aAltCurrencies ) ) {
01547 $aConfCurrencies = $aAltCurrencies;
01548 }
01549 } catch( Exception $e ) {
01550
01551 }
01552 }
01553 }
01554
01555
01556 $aCurrencies = array();
01557 reset( $aConfCurrencies );
01558 while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01559 if ( $val ) {
01560 $oCur = new oxStdClass();
01561 $oCur->id = $key;
01562 $sCur = explode( '@', $val);
01563 $oCur->name = trim( $sCur[0] );
01564 $oCur->rate = trim( $sCur[1] );
01565 $oCur->dec = trim( $sCur[2] );
01566 $oCur->thousand = trim( $sCur[3] );
01567 $oCur->sign = trim( $sCur[4] );
01568 $oCur->decimal = trim( $sCur[5] );
01569
01570
01571 if ( isset( $sCur[6] ) ) {
01572 $oCur->side = trim($sCur[6]);
01573 }
01574
01575 if ( isset( $iCurrency) && $key == $iCurrency ) {
01576 $oCur->selected = 1;
01577 } else {
01578 $oCur->selected = 0;
01579 }
01580 $aCurrencies[$key]= $oCur;
01581 }
01582
01583
01584 if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01585 break;
01586 }
01587 }
01588 return $aCurrencies;
01589 }
01590
01598 public function getCurrencyObject( $sName )
01599 {
01600 $aSearch = $this->getCurrencyArray();
01601 foreach ( $aSearch as $oCur ) {
01602 if ( $oCur->name == $sName ) {
01603 return $oCur;
01604 }
01605 }
01606 }
01607
01613 public function isDemoShop()
01614 {
01615 return $this->getConfigParam('blDemoShop');
01616 }
01617
01623 public function getEdition()
01624 {
01625 return "CE";
01626
01627
01628 }
01629
01635 public function getFullEdition()
01636 {
01637 $sEdition = $this->getEdition();
01638
01639 if ($sEdition == "CE") {
01640 return "Community Edition";
01641 }
01642
01643
01644
01645 return $sEdition;
01646 }
01647
01653 public function getVersion()
01654 {
01655 $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01656 return $sVersion;
01657 }
01658
01664 public function getRevision()
01665 {
01666 try {
01667 $sFileName = getShopBasePath() . "/pkg.rev";
01668 $iRev = (int) trim(@file_get_contents($sFileName));
01669 } catch (Exception $e) {
01670 return false;
01671 }
01672
01673 if (!$iRev) {
01674 return false;
01675 }
01676
01677 return $iRev;
01678 }
01679
01680
01686 public function isMall()
01687 {
01688
01689 return false;
01690 }
01691
01701 public function detectVersion()
01702 {
01703 }
01704
01705
01706
01718 public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null )
01719 {
01720 switch ( $sVarType ) {
01721 case 'arr':
01722 case 'aarr':
01723 if (is_array($sVarVal)) {
01724 $sValue = serialize( $sVarVal );
01725 } else {
01726
01727 $sValue = $sVarVal ;
01728 $sVarVal = unserialize( $sVarVal );
01729 }
01730 break;
01731 case 'bool':
01732 $sValue = $sVarVal = ( $sVarVal == 'true' || $sVarVal == '1' );
01733 break;
01734 default:
01735 $sValue = $sVarVal;
01736 break;
01737 }
01738
01739 if ( !$sShopId ) {
01740 $sShopId = $this->getShopId();
01741 }
01742
01743
01744 if ($sShopId == $this->getShopId()) {
01745 $this->setConfigParam( $sVarName, $sVarVal );
01746 }
01747
01748 $oDb = oxDb::getDb();
01749 $sQ = "delete from oxconfig where oxshopid = '$sShopId' and oxvarname = '$sVarName'";
01750 $oDb->execute( $sQ );
01751
01752 $sNewOXIDdQuoted = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
01753 $sShopIdQuoted = $oDb->quote($sShopId);
01754 $sVarNameQuoted = $oDb->quote($sVarName);
01755 $sVarTypeQuoted = $oDb->quote($sVarType);
01756 $sVarValueQuoted = $oDb->quote($sValue);
01757 $sConfigKeyQuoted = $oDb->quote($this->getConfigParam('sConfigKey'));
01758
01759 $sQ = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue)
01760 values($sNewOXIDdQuoted, $sShopIdQuoted, $sVarNameQuoted, $sVarTypeQuoted, ENCODE( $sVarValueQuoted, $sConfigKeyQuoted))";
01761
01762 $oDb->execute( $sQ );
01763 }
01764
01773 public function getShopConfVar( $sVarName, $sShopId = null )
01774 {
01775 if ( !$sShopId ) {
01776 $sShopId = $this->getShopId();
01777 }
01778
01779 $oDb = oxDb::getDb(true);
01780 $sQ = "select oxvartype, DECODE( oxvarvalue, '".$this->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '$sShopId' and oxvarname = ".$oDb->quote($sVarName);
01781 $oRs = $oDb->Execute( $sQ );
01782
01783 $sValue = null;
01784 if ( $oRs != false && $oRs->recordCount() > 0 ) {
01785 $sVarType = $oRs->fields['oxvartype'];
01786 $sVarVal = $oRs->fields['oxvarvalue'];
01787 switch ( $sVarType ) {
01788 case 'arr':
01789 case 'aarr':
01790 $sValue = unserialize( $sVarVal );
01791 break;
01792 case 'bool':
01793 $sValue = ( $sVarVal == 'true' || $sVarVal == '1' );
01794 break;
01795 default:
01796 $sValue = $sVarVal;
01797 break;
01798 }
01799 }
01800 return $sValue;
01801 }
01802
01808 public function isProductiveMode()
01809 {
01810 $blProductive = false;
01811
01812 $blProductive = $this->getConfigParam( 'blProductive' );
01813 if ( !isset( $blProductive ) ) {
01814 $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01815 $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01816 $this->setConfigParam( 'blProductive', $blProductive );
01817 }
01818
01819 return $blProductive;
01820 }
01821
01822
01823
01829 public function getBaseShopId()
01830 {
01831
01832 return 'oxbaseshop';
01833 }
01834
01840 public function getActiveShop()
01841 {
01842 if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01843 $this->_oActShop->getLanguage() == oxLang::getInstance()->getBaseLanguage() ) {
01844 return $this->_oActShop;
01845 }
01846
01847 $this->_oActShop = oxNew( 'oxshop' );
01848 $this->_oActShop->load( $this->getShopId() );
01849 return $this->_oActShop;
01850 }
01851
01857 public function getActiveView()
01858 {
01859 if ( $this->_oActView != null ) {
01860 return $this->_oActView;
01861 }
01862
01863 $this->_oActView = oxNew( 'oxubase' );
01864 return $this->_oActView;
01865 }
01866
01874 public function setActiveView( $oView )
01875 {
01876 $this->_oActView = $oView;
01877 }
01878
01884 public function isUtf()
01885 {
01886 return ( bool ) $this->getConfigParam( 'iUtfMode' );
01887 }
01888
01894 public function getLogsDir()
01895 {
01896 return $this->getConfigParam( 'sShopDir' ).'log/';
01897 }
01898 }