use Tygh\Bootstrap; use Tygh\Debugger; use Tygh\Registry; // Register autoloader $this_dir = dirname(__FILE__); $classLoader = (require $this_dir . '/app/lib/vendor/autoload.php'); $classLoader->add('Tygh', $this_dir . '/app'); class_alias('\\Tygh\\Tygh', 'Tygh'); // Prepare environment and process request vars list($_REQUEST, $_SERVER, $_GET, $_POST) = Bootstrap::initEnv($_GET, $_POST, $_SERVER, $this_dir); // Get config data $config = (require DIR_ROOT . '/config.php'); if (isset($_REQUEST['version'])) { die(PRODUCT_NAME . ' <b>' . PRODUCT_VERSION . ' ' . (PRODUCT_STATUS != '' ? ' (' . PRODUCT_STATUS . ')' : '') . (PRODUCT_BUILD != '' ? ' ' . PRODUCT_BUILD : '') . '</b>'); } Debugger::init(false, $config); // Start debugger log Debugger::checkpoint('Before init'); // Callback: verifies if https works if (isset($_REQUEST['check_https'])) { die(defined('HTTPS') ? 'OK' : ''); } // Check if software is installed if ($config['db_host'] == '%DB_HOST%') { die(PRODUCT_NAME . ' is <b>not installed</b>. Please click here to start the installation process: <a href="install/">[install]</a>'); } // Load core functions $fn_list = array('fn.database.php', 'fn.users.php', 'fn.catalog.php', 'fn.cms.php', 'fn.cart.php', 'fn.locations.php', 'fn.common.php', 'fn.fs.php', 'fn.images.php', 'fn.init.php', 'fn.control.php', 'fn.search.php', 'fn.promotions.php', 'fn.log.php', 'fn.companies.php', 'fn.addons.php'); $fn_list[] = 'fn.' . strtolower(PRODUCT_EDITION) . '.php'; foreach ($fn_list as $file) { require $config['dir']['functions'] . $file;
continue; } $result = call_user_func_array($function, $function_data); $status = !empty($result[0]) ? $result[0] : INIT_STATUS_OK; $url = !empty($result[1]) ? $result[1] : ''; $message = !empty($result[2]) ? $result[2] : ''; if ($status == INIT_STATUS_OK && !empty($url)) { $redirect_url = $url; } elseif ($status == INIT_STATUS_REDIRECT && !empty($url)) { $redirect_url = $url; break; } elseif ($status == INIT_STATUS_FAIL) { if (empty($message)) { $message = 'Initiation failed in <b>' . (is_array($function) ? implode('::', $function) : $function) . '</b> function'; } die($message); } } /* if (!empty($redirect_url)) { if (!defined('CART_LANGUAGE')) { fn_init_language($request); // we need CART_LANGUAGE in fn_url function that called in fn_redirect } fn_redirect($redirect_url); } */ $stack = Registry::get('init_stack'); if (!empty($stack)) { // New init functions were added to stack. Execute them fn_init($request); } Debugger::init(true);
/** * Run init functions * * @param array $request $_REQUEST global variable * @return bool always true */ function fn_init(&$request) { $stack = Registry::get('init_stack'); // Cleanup stack Registry::set('init_stack', array()); foreach ($stack as $function_data) { $function = array_shift($function_data); if (!is_callable($function)) { continue; } $result = call_user_func_array($function, $function_data); $status = !empty($result[0]) ? $result[0] : INIT_STATUS_OK; $url = !empty($result[1]) ? $result[1] : ''; $message = !empty($result[2]) ? $result[2] : ''; $permanent = !empty($result[3]) ? $result[3] : ''; if ($status == INIT_STATUS_OK && !empty($url)) { $redirect_url = $url; } elseif ($status == INIT_STATUS_REDIRECT && !empty($url)) { $redirect_url = $url; break; } elseif ($status == INIT_STATUS_FAIL) { if (empty($message)) { $message = 'Initialization failed in <b>' . (is_array($function) ? implode('::', $function) : $function) . '</b> function'; } throw new InitException($message); } } if (!empty($redirect_url)) { if (!defined('CART_LANGUAGE')) { fn_init_language($request); // we need CART_LANGUAGE in fn_url function that called in fn_redirect } fn_redirect($redirect_url, true, !empty($permanent)); } $stack = Registry::get('init_stack'); if (!empty($stack)) { // New init functions were added to stack. Execute them fn_init($request); } Debugger::init(true); return true; }
use Tygh\Bootstrap; use Tygh\Debugger; use Tygh\Exceptions\DatabaseException; use Tygh\Registry; // Register autoloader $this_dir = dirname(__FILE__); $classLoader = (require $this_dir . '/app/lib/vendor/autoload.php'); $classLoader->add('Tygh', $this_dir . '/app'); // Prepare environment and process request vars list($_REQUEST, $_SERVER) = Bootstrap::initEnv($_GET, $_POST, $_SERVER, $this_dir); // Get config data $config = (require DIR_ROOT . '/config.php'); if (isset($_REQUEST['version'])) { die(PRODUCT_NAME . ' <b>' . PRODUCT_VERSION . ' ' . (PRODUCT_STATUS != '' ? ' (' . PRODUCT_STATUS . ')' : '') . (PRODUCT_BUILD != '' ? ' ' . PRODUCT_BUILD : '') . '</b>'); } Debugger::init(); // Start debugger log Debugger::checkpoint('Before init'); // Callback: verifies if https works if (isset($_REQUEST['check_https'])) { die(defined('HTTPS') ? 'OK' : ''); } // Check if software is installed if ($config['db_host'] == '%DB_HOST%') { die(PRODUCT_NAME . ' is <b>not installed</b>. Please click here to start the installation process: <a href="install/">[install]</a>'); } // Load core functions $fn_list = array('fn.database.php', 'fn.users.php', 'fn.catalog.php', 'fn.cms.php', 'fn.cart.php', 'fn.locations.php', 'fn.common.php', 'fn.fs.php', 'fn.images.php', 'fn.init.php', 'fn.control.php', 'fn.search.php', 'fn.promotions.php', 'fn.log.php', 'fn.companies.php', 'fn.addons.php'); $fn_list[] = 'fn.' . strtolower(PRODUCT_EDITION) . '.php'; foreach ($fn_list as $file) { require $config['dir']['functions'] . $file;