shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

startup.php (3343B)


      1 <?php
      2 // Error Reporting
      3 error_reporting(E_ALL);
      4 
      5 // Check Version
      6 if (version_compare(phpversion(), '5.4.0', '<') == true) {
      7 	exit('PHP5.4+ Required');
      8 }
      9 
     10 if (!ini_get('date.timezone')) {
     11 	date_default_timezone_set('UTC');
     12 }
     13 
     14 // Windows IIS Compatibility
     15 if (!isset($_SERVER['DOCUMENT_ROOT'])) {
     16 	if (isset($_SERVER['SCRIPT_FILENAME'])) {
     17 		$_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF'])));
     18 	}
     19 }
     20 
     21 if (!isset($_SERVER['DOCUMENT_ROOT'])) {
     22 	if (isset($_SERVER['PATH_TRANSLATED'])) {
     23 		$_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 - strlen($_SERVER['PHP_SELF'])));
     24 	}
     25 }
     26 
     27 if (!isset($_SERVER['REQUEST_URI'])) {
     28 	$_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);
     29 
     30 	if (isset($_SERVER['QUERY_STRING'])) {
     31 		$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
     32 	}
     33 }
     34 
     35 if (!isset($_SERVER['HTTP_HOST'])) {
     36 	$_SERVER['HTTP_HOST'] = getenv('HTTP_HOST');
     37 }
     38 
     39 // Check if SSL
     40 if ((isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) || (isset($_SERVER['HTTPS']) && (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443))) {
     41 	$_SERVER['HTTPS'] = true;
     42 } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
     43 	$_SERVER['HTTPS'] = true;
     44 } else {
     45 	$_SERVER['HTTPS'] = false;
     46 }
     47 
     48 // Modification Override
     49 function modification($filename) {
     50 	if (defined('DIR_CATALOG')) {
     51 		$file = DIR_MODIFICATION . 'admin/' .  substr($filename, strlen(DIR_APPLICATION));
     52 	} elseif (defined('DIR_OPENCART')) {
     53 		$file = DIR_MODIFICATION . 'install/' .  substr($filename, strlen(DIR_APPLICATION));
     54 	} else {
     55 		$file = DIR_MODIFICATION . 'catalog/' . substr($filename, strlen(DIR_APPLICATION));
     56 	}
     57 
     58 	if (substr($filename, 0, strlen(DIR_SYSTEM)) == DIR_SYSTEM) {
     59 		$file = DIR_MODIFICATION . 'system/' . substr($filename, strlen(DIR_SYSTEM));
     60 	}
     61 
     62 	if (is_file($file)) {
     63 		return $file;
     64 	}
     65 
     66 	return $filename;
     67 }
     68 
     69 // Autoloader
     70 if (is_file(DIR_STORAGE . 'vendor/autoload.php')) {
     71 	require_once(DIR_STORAGE . 'vendor/autoload.php');
     72 }
     73 
     74 function library($class) {
     75 	$file = DIR_SYSTEM . 'library/' . str_replace('\\', '/', strtolower($class)) . '.php';
     76 
     77 	if (is_file($file)) {
     78 		include_once(modification($file));
     79 
     80 		return true;
     81 	} else {
     82 		return false;
     83 	}
     84 }
     85 
     86 spl_autoload_register('library');
     87 spl_autoload_extensions('.php');
     88 
     89 // Engine
     90 require_once(modification(DIR_SYSTEM . 'engine/action.php'));
     91 require_once(modification(DIR_SYSTEM . 'engine/controller.php'));
     92 require_once(modification(DIR_SYSTEM . 'engine/event.php'));
     93 require_once(modification(DIR_SYSTEM . 'engine/router.php'));
     94 require_once(modification(DIR_SYSTEM . 'engine/loader.php'));
     95 require_once(modification(DIR_SYSTEM . 'engine/model.php'));
     96 require_once(modification(DIR_SYSTEM . 'engine/registry.php'));
     97 require_once(modification(DIR_SYSTEM . 'engine/proxy.php'));
     98 
     99 // Helper
    100 require_once(DIR_SYSTEM . 'helper/general.php');
    101 require_once(DIR_SYSTEM . 'helper/utf8.php');
    102 
    103 function start($application_config) {
    104 	require_once(DIR_SYSTEM . 'framework.php');	
    105 }