1: | <?php
2: | namespace Opencart\Catalog\Controller\Startup;
3: | /**
4: | * Class Setting
5: | *
6: | * @package Opencart\Catalog\Controller\Startup
7: | */
8: | class Setting extends \Opencart\System\Engine\Controller {
9: | /**
10: | * @return void
11: | */
12: | public function index(): void {
13: | $hostname = ($this->request->server['HTTPS'] ? 'https://' : 'http://') . str_replace('www.', '', $this->request->server['HTTP_HOST']) . rtrim(dirname($this->request->server['PHP_SELF']), '/.\\') . '/';
14: |
15: | $this->load->model('setting/store');
16: |
17: | $store_info = $this->model_setting_store->getStoreByHostname($hostname);
18: |
19: | // Store
20: | if (isset($this->request->get['store_id'])) {
21: | $this->config->set('config_store_id', (int)$this->request->get['store_id']);
22: | } elseif ($store_info) {
23: | $this->config->set('config_store_id', $store_info['store_id']);
24: | } else {
25: | $this->config->set('config_store_id', 0);
26: | }
27: |
28: | if (!$store_info) {
29: | // If catalog constant is defined
30: | if (defined('HTTP_CATALOG')) {
31: | $this->config->set('config_url', HTTP_CATALOG);
32: | } else {
33: | $this->config->set('config_url', HTTP_SERVER);
34: | }
35: | }
36: |
37: | // Settings
38: | $this->load->model('setting/setting');
39: |
40: | $results = $this->model_setting_setting->getSettings($this->config->get('config_store_id'));
41: |
42: | foreach ($results as $result) {
43: | if (!$result['serialized']) {
44: | $this->config->set($result['key'], $result['value']);
45: | } else {
46: | $this->config->set($result['key'], json_decode($result['value'], true));
47: | }
48: | }
49: |
50: | // Url
51: | $this->registry->set('url', new \Opencart\System\Library\Url($this->config->get('config_url')));
52: |
53: | // Set time zone
54: | if ($this->config->get('config_timezone')) {
55: | date_default_timezone_set($this->config->get('config_timezone'));
56: |
57: | // Sync PHP and DB time zones.
58: | $this->db->query("SET time_zone = '" . $this->db->escape(date('P')) . "'");
59: | }
60: |
61: | // Response output compression level
62: | if ($this->config->get('config_compression')) {
63: | $this->response->setCompression((int)$this->config->get('config_compression'));
64: | }
65: | }
66: | }
67: |

OpenCart API API documentation generated by ApiGen dev-master