diff options
author | Jesús <heckyel@hyperbola.info> | 2019-08-18 21:14:58 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2019-08-18 21:14:58 -0500 |
commit | 2eed7b082f83630301e51f57ca8394de228a8605 (patch) | |
tree | 1d19962d22d30f99317d9276e4bae7744fc93fc2 /public/install/controller/startup | |
download | librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.lz librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.xz librecart-2eed7b082f83630301e51f57ca8394de228a8605.zip |
first commit
Diffstat (limited to 'public/install/controller/startup')
-rw-r--r-- | public/install/controller/startup/database.php | 22 | ||||
-rw-r--r-- | public/install/controller/startup/language.php | 33 | ||||
-rw-r--r-- | public/install/controller/startup/router.php | 10 | ||||
-rw-r--r-- | public/install/controller/startup/upgrade.php | 20 |
4 files changed, 85 insertions, 0 deletions
diff --git a/public/install/controller/startup/database.php b/public/install/controller/startup/database.php new file mode 100644 index 0000000..a4cf4cf --- /dev/null +++ b/public/install/controller/startup/database.php @@ -0,0 +1,22 @@ +<?php +class ControllerStartupDatabase extends Controller { + public function index() { + if (is_file(DIR_OPENCART . 'config.php') && filesize(DIR_OPENCART . 'config.php') > 0) { + $lines = file(DIR_OPENCART . 'config.php'); + + foreach ($lines as $line) { + if (strpos(strtoupper($line), 'DB_') !== false) { + eval($line); + } + } + + if (defined('DB_PORT')) { + $port = DB_PORT; + } else { + $port = ini_get('mysqli.default_port'); + } + + $this->registry->set('db', new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, $port)); + } + } +}
\ No newline at end of file diff --git a/public/install/controller/startup/language.php b/public/install/controller/startup/language.php new file mode 100644 index 0000000..3055f60 --- /dev/null +++ b/public/install/controller/startup/language.php @@ -0,0 +1,33 @@ +<?php +class ControllerStartupLanguage extends Controller { + public function index() { + // Default language code + $code = $this->config->get('language_default'); + + $languages = glob(DIR_LANGUAGE . '*', GLOB_ONLYDIR); + + foreach ($languages as $language) { + $languages[] = basename($language); + } + + if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { + $browser_languages = explode(',', $this->request->server['HTTP_ACCEPT_LANGUAGE']); + + foreach ($browser_languages as $browser_language) { + if (in_array($browser_language, $languages)) { + $code = $browser_language; + break; + } + } + } + + if (!isset($this->session->data['language']) || !is_dir(DIR_LANGUAGE . basename($this->session->data['language']))) { + $this->session->data['language'] = $code; + } + + // Language + $language = new Language($this->session->data['language']); + $language->load($this->session->data['language']); + $this->registry->set('language', $language); + } +} diff --git a/public/install/controller/startup/router.php b/public/install/controller/startup/router.php new file mode 100644 index 0000000..13cd146 --- /dev/null +++ b/public/install/controller/startup/router.php @@ -0,0 +1,10 @@ +<?php +class ControllerStartupRouter extends Controller { + public function index() { + if (isset($this->request->get['route']) && $this->request->get['route'] != 'action/route') { + return new Action($this->request->get['route']); + } else { + return new Action($this->config->get('action_default')); + } + } +}
\ No newline at end of file diff --git a/public/install/controller/startup/upgrade.php b/public/install/controller/startup/upgrade.php new file mode 100644 index 0000000..abc9ddd --- /dev/null +++ b/public/install/controller/startup/upgrade.php @@ -0,0 +1,20 @@ +<?php +class ControllerStartupUpgrade extends Controller { + public function index() { + $upgrade = false; + + if (is_file(DIR_OPENCART . 'config.php') && filesize(DIR_OPENCART . 'config.php') > 0) { + $upgrade = true; + } + + if (isset($this->request->get['route'])) { + if (($this->request->get['route'] == 'install/step_4') || (substr($this->request->get['route'], 0, 8) == 'upgrade/') || (substr($this->request->get['route'], 0, 10) == '3rd_party/')) { + $upgrade = false; + } + } + + if ($upgrade) { + $this->response->redirect($this->url->link('upgrade/upgrade')); + } + } +}
\ No newline at end of file |