-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathConfig.php
2331 lines (2060 loc) · 64.1 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Core;
use Exception;
use OxidEsales\Eshop\Application\Controller\OxidStartController;
use OxidEsales\Eshop\Application\Model\Shop;
use OxidEsales\Eshop\Core\Module\ModuleTemplatePathCalculator;
use OxidEsales\EshopCommunity\Internal\Framework\Theme\Bridge\AdminThemeBridgeInterface;
use stdClass;
use OxidEsales\Eshop\Application\Controller\FrontendController;
use OxidEsales\EshopCommunity\Internal\Framework\Config\Event\ShopConfigurationChangedEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Event\SettingChangedEvent;
use OxidEsales\EshopCommunity\Internal\Framework\Theme\Event\ThemeSettingChangedEvent;
//max integer
define('MAX_64BIT_INTEGER', '18446744073709551615');
/**
* Main shop configuration class.
*
* @mixin \OxidEsales\EshopEnterprise\Core\Config
* @mixin \OxidEsales\EshopProfessional\Core\Config
*/
class Config extends \OxidEsales\Eshop\Core\Base
{
// this column of params are defined in config.inc.php file,
// so for backwards compatibility. names starts without underscore
/**
* Database host name
*
* @var string
*/
protected $dbHost = null;
/**
* Database name
*
* @var string
*/
protected $dbName = null;
/**
* Database user name
*
* @var string
*/
protected $dbUser = null;
/**
* Database user password
*
* @var string
*/
protected $dbPwd = null;
/**
* Database driver type
*
* @var string
*/
protected $dbType = null;
/**
* Shop Url
*
* @var string
*/
protected $sShopURL = null;
/**
* Shop SSL mode Url
*
* @var string
*/
protected $sSSLShopURL = null;
/**
* Shops admin SSL mode Url
*
* @var string
*/
protected $sAdminSSLURL = null;
/**
* Shops install directory
*
* @var string
*/
protected $sShopDir = null;
/**
* Shops compile directory
*
* @var string
*/
protected $sCompileDir = null;
/**
* Debug mode (default is set depending on if it is productive mode or not):
* -1 = Logger Messages internal use only
* 0 = off
* 1 = smarty
* 2 = SQL
* 3 = SQL + smarty
* 4 = SQL + smarty + shop template data
* 5 = Delivery Cost calculation info
* 6 = SMTP Debug Messages
* 7 = Slow SQL query indication
*
* @var int
*/
protected $iDebug = null;
/**
* Administrator email address, used to send critical notices
*
* @var string
*/
protected $sAdminEmail = null;
/**
* Use cookies
*
* @var bool
*/
protected $blSessionUseCookies = null;
/**
* Default image loading location.
* If $blNativeImages is set to true the shop loads images from current domain,
* otherwise images are loaded from the domain specified in config.inc.php.
* This is applicable for different domains depending on language or mall
* if mall mode is available.
*
* @var bool
*/
protected $blNativeImages = true;
/**
* Only for multishops
* Unload news from all shops in multishop.
* If $blOtherShopNews is set to true the multishop does not load news from all shops,
* This is applicable for depending on mall
* if mall mode is available.
*
* @var bool
*/
protected $blDoNotLoadAllShopNews = true;
/**
* Names of tables which are multi-shop
*
* @var array
*/
protected $aMultiShopTables = ['oxarticles', 'oxdiscount', 'oxcategories', 'oxattribute',
'oxlinks', 'oxvoucherseries', 'oxmanufacturers',
// @deprecated since v.5.3.0 (2016-06-17); The Admin Menu: Customer Info -> News feature will be moved to a module in v6.0.0
'oxnews',
// END deprecated
'oxselectlist', 'oxwrapping',
'oxdeliveryset', 'oxdelivery', 'oxvendor', 'oxobject2category'];
/**
* Application starter instance
*
* @var OxidStartController
*/
private $_oStart = null;
/**
* Active shop object.
*
* @var object
*/
protected $_oActShop = null;
/**
* Active Views object array. Object has setters/getters for these properties:
* _sClass - name of current view class
* _sFnc - name of current action function
*
* @var array
*/
protected $_aActiveViews = [];
/**
* Array of global parameters.
*
* @var array
*/
protected $_aGlobalParams = [];
/**
* Shop config parameters storage array
*
* @var array
*/
protected $_aConfigParams = [];
/**
* Theme config parameters storage array
*
* @var array
*/
protected $_aThemeConfigParams = [];
/**
* Current language Id
*
* @var int
*/
protected $_iLanguageId = null;
/**
* Current shop Id
*
* @var int
*/
protected $_iShopId = null;
/**
* Out dir name
*
* @var string
*/
protected $_sOutDir = 'out';
/**
* Image dir name
*
* @var string
*/
protected $_sImageDir = 'img';
/**
* Dyn Image dir name
*
* @var string
*/
protected $_sPictureDir = 'pictures';
/**
* Master pictures dir name
*
* @var string
*/
protected $_sMasterPictureDir = 'master';
/**
* Template dir name
*
* @var string
*/
protected $_sTemplateDir = 'tpl';
/**
* Resource dir name
*
* @var string
*/
protected $_sResourceDir = 'src';
/**
* Modules dir name
*
* @var string
*/
protected $_sModulesDir = 'modules';
/**
* Whether shop is in SSL mode
*
* @var bool
*/
protected $_blIsSsl = null;
/**
* Absolute image dirs for each shops
*
* @var array
*/
protected $_aAbsDynImageDir = [];
/**
* Active currency object
*
* @var array
*/
protected $_oActCurrencyObject = null;
/**
* Indicates if Config::init() method has been already run.
* Is checked for loading config variables on demand.
* Used in Config::getConfigParam() method
*
* @var bool
*/
protected $_blInit = false;
/**
* prefix for oxModule field for themes in oxConfig and oxConfigDisplay tables
*
* @var string
*/
const OXMODULE_THEME_PREFIX = 'theme:';
/**
* prefix for oxModule field for modules in oxConfig and oxConfigDisplay tables
*
* @var string
*/
const OXMODULE_MODULE_PREFIX = 'module:';
/**
* Returns config parameter value if such parameter exists
*
* @param string $name config parameter name
* @param mixed $default default value if no config var is found default null
*
* @return mixed
*/
public function getConfigParam($name, $default = null)
{
$this->init();
if (isset($this->_aConfigParams[$name])) {
$value = $this->_aConfigParams[$name];
} elseif (isset($this->$name)) {
$value = $this->$name;
} else {
$value = $default;
}
return $value;
}
/**
* Stores config parameter value in config
*
* @param string $name config parameter name
* @param mixed $value config parameter value
*/
public function setConfigParam($name, $value)
{
if (isset($this->_aConfigParams[$name])) {
$this->_aConfigParams[$name] = $value;
} elseif (isset($this->$name)) {
$this->$name = $value;
} else {
$this->_aConfigParams[$name] = $value;
}
}
/**
* Parse SEO url parameters.
*/
protected function _processSeoCall() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
// TODO: refactor shop bootstrap and parse url params as soon as possible
if (isSearchEngineUrl()) {
oxNew(\OxidEsales\Eshop\Core\SeoDecoder::class)->processSeoCall();
}
}
/**
* Initialize configuration variables
*
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseException
* @param int $shopId
*/
public function initVars($shopId)
{
$this->_loadVarsFromFile();
$this->_setDefaults();
$configLoaded = $this->_loadVarsFromDb($shopId);
// loading shop config
if (empty($shopId) || !$configLoaded) {
// if no config values where loaded (some problems with DB), throwing an exception
$exception = new \OxidEsales\Eshop\Core\Exception\DatabaseException(
"Unable to load shop config values from database",
0,
new \Exception()
);
throw $exception;
}
// loading theme config options
$this->_loadVarsFromDb($shopId, null, Config::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme'));
// checking if custom theme (which has defined parent theme) config options should be loaded over parent theme (#3362)
if ($this->getConfigParam('sCustomTheme')) {
$this->_loadVarsFromDb($shopId, null, Config::OXMODULE_THEME_PREFIX . $this->getConfigParam('sCustomTheme'));
}
// loading modules config
$this->_loadVarsFromDb($shopId, null, Config::OXMODULE_MODULE_PREFIX);
$this->loadAdditionalConfiguration();
// Admin handling
$this->setConfigParam('blAdmin', isAdmin());
if (defined('OX_ADMIN_DIR')) {
$this->setConfigParam('sAdminDir', OX_ADMIN_DIR);
}
$this->_loadVarsFromFile();
}
/**
* Starts session manager
*
* @return null
*/
public function init()
{
// Duplicated init protection
if ($this->_blInit) {
return;
}
$this->_blInit = true;
try {
// config params initialization
$this->initVars($this->getShopId());
// application initialization
$this->initializeShop();
$this->_oStart = oxNew(\OxidEsales\Eshop\Application\Controller\OxidStartController::class);
$this->_oStart->appInit();
} catch (\OxidEsales\Eshop\Core\Exception\DatabaseException $exception) {
$this->_handleDbConnectionException($exception);
} catch (\OxidEsales\Eshop\Core\Exception\CookieException $exception) {
$this->_handleCookieException($exception);
}
}
/**
* Reloads all configuration.
*/
public function reinitialize()
{
$this->_blInit = false;
$this->init();
}
/**
* Load any additional configuration on Config::init.
*/
protected function loadAdditionalConfiguration()
{
}
/**
* Initializes main shop tasks - processing of SEO calls, starting of session.
*/
protected function initializeShop()
{
$this->_processSeoCall();
$session = \OxidEsales\Eshop\Core\Registry::getSession();
$session->start();
}
/**
* Loads vars from default config file
*/
protected function _loadVarsFromFile() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
//config variables from config.inc.php takes priority over the ones loaded from db
include getShopBasePath() . '/config.inc.php';
//adding trailing slashes
$fileUtils = Registry::getUtilsFile();
$this->sShopDir = $fileUtils->normalizeDir($this->sShopDir);
$this->sCompileDir = $fileUtils->normalizeDir($this->sCompileDir);
$this->sShopURL = $fileUtils->normalizeDir($this->sShopURL);
$this->sSSLShopURL = $fileUtils->normalizeDir($this->sSSLShopURL);
$this->sAdminSSLURL = $fileUtils->normalizeDir($this->sAdminSSLURL);
$this->_loadCustomConfig();
}
/**
* Set important defaults.
*/
protected function _setDefaults() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
$this->setConfigParam('sTheme', 'azure');
if (is_null($this->getConfigParam('sDefaultLang'))) {
$this->setConfigParam('sDefaultLang', 0);
}
if (is_null($this->getConfigParam('blLogChangesInAdmin'))) {
$this->setConfigParam('blLogChangesInAdmin', false);
}
if (is_null($this->getConfigParam('blCheckTemplates'))) {
$this->setConfigParam('blCheckTemplates', false);
}
if (is_null($this->getConfigParam('blAllowArticlesubclass'))) {
$this->setConfigParam('blAllowArticlesubclass', false);
}
if (is_null($this->getConfigParam('iAdminListSize'))) {
$this->setConfigParam('iAdminListSize', 9);
}
// #1173M for EE - not all pic are deleted
if (is_null($this->getConfigParam('iPicCount'))) {
$this->setConfigParam('iPicCount', 12);
}
if (is_null($this->getConfigParam('iZoomPicCount'))) {
$this->setConfigParam('iZoomPicCount', 4);
}
if (is_null($this->getConfigParam('iDebug'))) {
$this->setConfigParam('iDebug', $this->isProductiveMode() ? 0 : -1);
}
$this->setConfigParam('sCoreDir', __DIR__ . DIRECTORY_SEPARATOR);
}
/**
* Loads vars from custom config file
*/
protected function _loadCustomConfig() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
$custConfig = getShopBasePath() . '/cust_config.inc.php';
if (is_readable($custConfig)) {
include $custConfig;
}
}
/**
* Load config values from DB
*
* @param int $shopId shop ID to load parameters
* @param array $onlyVars array of params to load (optional)
* @param string $module module vars to load, empty for base options
*
* @return bool
*/
protected function _loadVarsFromDb($shopId, $onlyVars = null, $module = '') // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
$db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
$params = [
':oxshopid' => $shopId
];
$select = "select
oxvarname, oxvartype, oxvarvalue
from oxconfig
where oxshopid = :oxshopid and ";
if ($module) {
$select .= " oxmodule LIKE :oxmodule";
$params[':oxmodule'] = $module;
} else {
$select .= "oxmodule = ''";
}
$select .= $this->_getConfigParamsSelectSnippet($onlyVars);
$result = $db->getAll($select, $params);
foreach ($result as $value) {
$varName = $value[0];
$varType = $value[1];
$varVal = $value[2];
$this->_setConfVarFromDb($varName, $varType, $varVal);
//setting theme options array
if ($module) {
$this->_aThemeConfigParams[$varName] = $module;
}
}
return (bool) count($result);
}
/**
* Allow loading from some vars only from baseshop
*
* @param array $vars
*
* @return string
*/
protected function _getConfigParamsSelectSnippet($vars) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
$select = '';
if (is_array($vars) && !empty($vars)) {
foreach ($vars as &$field) {
$field = '"' . $field . '"';
}
$select = ' and oxvarname in ( ' . implode(', ', $vars) . ' ) ';
}
return $select;
}
/**
* Sets config variable to config object, first unserializing it by given type.
* sShopURL and sSSLShopURL are skipped for admin or when URL values are not set
*
* @param string $varName variable name
* @param string $varType variable type - arr, aarr, bool or str
* @param string $varVal serialized by type value
*
* @return null
*/
protected function _setConfVarFromDb($varName, $varType, $varVal) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
if (
($varName == 'sShopURL' || $varName == 'sSSLShopURL') &&
(!$varVal || $this->isAdmin() === true)
) {
return;
}
switch ($varType) {
case 'arr':
case 'aarr':
$this->setConfigParam($varName, unserialize($varVal));
break;
case 'bool':
$this->setConfigParam($varName, ($varVal == 'true' || $varVal == '1'));
break;
default:
$this->setConfigParam($varName, $varVal);
break;
}
}
/**
* Unsets all session data.
*
* @return null
*/
public function pageClose()
{
if ($this->hasActiveViewsChain()) {
// do not commit session until active views chain exists
return;
}
return $this->_oStart->pageClose();
}
/**
* Returns value of parameter stored in POST,GET.
* For security reasons performed Config->checkParamSpecialChars().
* use $raw very carefully if you want to get unescaped
* parameter.
*
* @param string $name Name of parameter.
* @param bool $raw Get unescaped parameter.
*
* @deprecated on b-dev (2015-06-10); Use Request::getRequestEscapedParameter().
*
* @return mixed
*/
public function getRequestParameter($name, $raw = false)
{
$request = Registry::get(\OxidEsales\Eshop\Core\Request::class);
return $raw ? $request->getRequestParameter($name) : $request->getRequestEscapedParameter($name);
}
/**
* Returns escaped value of parameter stored in POST,GET.
*
* @param string $name Name of parameter.
* @param string $defaultValue Default value if no value provided.
*
* @deprecated on 6.0.0 (2016-05-16); use OxidEsales\Eshop\Core\Request::getRequestEscapedParameter()
*
* @return mixed
*/
public function getRequestEscapedParameter($name, $defaultValue = null)
{
return Registry::get(\OxidEsales\Eshop\Core\Request::class)->getRequestEscapedParameter($name, $defaultValue);
}
/**
* Returns raw value of parameter stored in POST,GET.
*
* @param string $name Name of parameter.
* @param string $defaultValue Default value if no value provided.
*
* @deprecated on 6.0.0 (2016-05-16); use OxidEsales\Eshop\Core\Request::getRequestEscapedParameter()
*
* @return mixed
*/
public function getRequestRawParameter($name, $defaultValue = null)
{
return Registry::get(\OxidEsales\Eshop\Core\Request::class)->getRequestParameter($name, $defaultValue);
}
/**
* Get request 'cl' parameter which is the controller id.
*
* @return string|null
*/
public function getRequestControllerId()
{
return $this->getRequestParameter('cl');
}
/**
* Use this function to get the controller class hidden behind the request's 'cl' parameter.
*
* @return mixed
*/
public function getRequestControllerClass()
{
$controllerId = $this->getRequestControllerId();
$controllerClass = Registry::getControllerClassNameResolver()->getClassNameById($controllerId);
return $controllerClass;
}
/**
* Returns uploaded file parameter
*
* @param string $paramName param name
*
* @return null
*/
public function getUploadedFile($paramName)
{
return $_FILES[$paramName];
}
/**
* Sets global parameter value
*
* @param string $name name of parameter
* @param mixed $value value to store
*/
public function setGlobalParameter($name, $value)
{
$this->_aGlobalParams[$name] = $value;
}
/**
* Returns global parameter value
*
* @param string $name name of cached parameter
*
* @return mixed
*/
public function getGlobalParameter($name)
{
if (isset($this->_aGlobalParams[$name])) {
return $this->_aGlobalParams[$name];
} else {
return null;
}
}
/**
* Checks if passed parameter has special chars and replaces them.
* Returns checked value.
*
* @param mixed $value value to process escaping
* @param array $raw keys of unescaped values
*
* @return mixed
*/
public function checkParamSpecialChars(&$value, $raw = null)
{
return Registry::get(\OxidEsales\Eshop\Core\Request::class)->checkParamSpecialChars($value, $raw);
}
/**
* Active Shop id setter
*
* @param int $shopId shop id
*/
public function setShopId($shopId)
{
$session = \OxidEsales\Eshop\Core\Registry::getSession();
$session->setVariable('actshop', $shopId);
$this->_iShopId = $shopId;
}
/**
* Returns active shop ID.
*
* @return int
*/
public function getShopId()
{
if (is_null($this->_iShopId)) {
$shopId = $this->calculateActiveShopId();
$this->setShopId($shopId);
if (!$this->_isValidShopId($shopId)) {
$shopId = $this->getBaseShopId();
}
$this->setShopId($shopId);
}
return $this->_iShopId;
}
/**
* Set is shop url
*
* @param bool $isSsl - state bool value
*/
public function setIsSsl($isSsl = false)
{
$this->_blIsSsl = $isSsl;
}
/**
* Checks if WEB session is SSL.
*/
protected function _checkSsl() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
$myUtilsServer = Registry::getUtilsServer();
$serverVars = $myUtilsServer->getServerVar();
$httpsServerVar = $myUtilsServer->getServerVar('HTTPS');
$this->setIsSsl();
if (isset($httpsServerVar) && ($httpsServerVar === 'on' || $httpsServerVar === 'ON' || $httpsServerVar == '1')) {
// "1&1" hoster provides "1"
$this->setIsSsl($this->getConfigParam('sSSLShopURL') || $this->getConfigParam('sMallSSLShopURL'));
if ($this->isAdmin() && !$this->_blIsSsl) {
//#4026
$this->setIsSsl(!is_null($this->getConfigParam('sAdminSSLURL')));
}
}
//additional special handling for profihost customers
if (
isset($serverVars['HTTP_X_FORWARDED_SERVER']) &&
(strpos($serverVars['HTTP_X_FORWARDED_SERVER'], 'ssl') !== false ||
strpos($serverVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de') !== false)
) {
$this->setIsSsl(true);
}
}
/**
* Checks if WEB session is SSL. Returns true if yes.
*
* @return bool
*/
public function isSsl()
{
if (is_null($this->_blIsSsl)) {
$this->_checkSsl();
}
return $this->_blIsSsl;
}
/**
* Checks if shop runs in https only mode
* https only mode means there is no http url but only a https url
*
* @return bool
*/
public function isHttpsOnly()
{
return $this->isSsl() && $this->getSslShopUrl() == $this->getShopUrl();
}
/**
* Compares current URL to supplied string
*
* @param string $url URL
*
* @return bool true if $url is equal to current page URL
*/
public function isCurrentUrl($url)
{
/** @var UtilsServer $utilsServer */
$utilsServer = Registry::getUtilsServer();
return $utilsServer->isCurrentUrl($url);
}
/**
* Compares current protocol to supplied url string
*
* @param string $url URL
*
* @return bool true if $url is equal to current page URL
*/
public function isCurrentProtocol($url)
{
// Missing protocol, cannot proceed, assuming true.
if (!$url || (strpos($url, "http") !== 0)) {
return true;
}
return (strpos($url, "https:") === 0) == $this->isSsl();
}
/**
* Returns config sShopURL or sMallShopURL if secondary shop
*
* @param int $lang language
* @param bool $admin if set true, function returns shop url without checking language/subshops for different url.
*
* @return string
*/
public function getShopUrl($lang = null, $admin = null)
{
$url = null;
$admin = isset($admin) ? $admin : $this->isAdmin();
if (!$admin) {
$url = $this->getShopUrlByLanguage($lang);
if (!$url) {
$url = $this->getMallShopUrl();
}
}
if (!$url) {
$url = $this->getConfigParam('sShopURL');
}
return $url;
}
/**
* Returns config sSSLShopURL or sMallSSLShopURL if secondary shop
*
* @param int $lang language (default is null)
*
* @return string
*/
public function getSslShopUrl($lang = null)
{
$url = $this->getShopUrlByLanguage($lang, true);
if (!$url) {
$url = $this->getMallShopUrl(true);
}
if (!$url) {
$url = $this->getMallShopUrl();
}
//normal section
if (!$url) {
$url = $this->getConfigParam('sSSLShopURL');
}
if (!$url) {
$url = $this->getShopUrl($lang);
}
return $url;
}
/**
* Returns utils dir URL
*
* @return string
*/
public function getCoreUtilsUrl()
{
return $this->getCurrentShopUrl() . 'Core/utils/';
}
/**
* Returns SSL or non SSL shop URL without index.php depending on Mall
* affecting environment is admin mode and current ssl usage status
*
* @param bool $admin if admin
*
* @return string
*/
public function getCurrentShopUrl($admin = null)
{
if ($admin === null) {
$admin = $this->isAdmin();
}
if ($admin) {
if ($this->isSsl()) {
$url = $this->getConfigParam('sAdminSSLURL');
if (!$url) {
return $this->getSslShopUrl() . $this->getConfigParam('sAdminDir') . '/';