| 1: | <?php
|
| 2: | namespace Opencart\Catalog\Controller\Startup;
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class Setting extends \Opencart\System\Engine\Controller {
|
| 9: | |
| 10: | |
| 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: |
|
| 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: |
|
| 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: |
|
| 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: |
|
| 51: | $this->registry->set('url', new \Opencart\System\Library\Url($this->config->get('config_url')));
|
| 52: |
|
| 53: |
|
| 54: | if ($this->config->get('config_timezone')) {
|
| 55: | date_default_timezone_set($this->config->get('config_timezone'));
|
| 56: |
|
| 57: |
|
| 58: | $this->db->query("SET time_zone = '" . $this->db->escape(date('P')) . "'");
|
| 59: | }
|
| 60: |
|
| 61: |
|
| 62: | if ($this->config->get('config_compression')) {
|
| 63: | $this->response->setCompression((int)$this->config->get('config_compression'));
|
| 64: | }
|
| 65: | }
|
| 66: | }
|
| 67: | |