123 lines
4.4 KiB
PHP
123 lines
4.4 KiB
PHP
<?php
|
|
define('MorvalWatches', true);
|
|
|
|
// Determine the base URL
|
|
$base_url = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ? 'https' : 'http';
|
|
$base_url .= '://' . rtrim($_SERVER['HTTP_HOST'], '/');
|
|
$base_url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 || strpos($_SERVER['HTTP_HOST'], ':') !== false ? '' : ':' . $_SERVER['SERVER_PORT'];
|
|
$base_url .= '/' . ltrim(substr(str_replace('\\', '/', realpath(__DIR__)), strlen($_SERVER['DOCUMENT_ROOT'])), '/');
|
|
|
|
define('base_url', rtrim($base_url, '/') . '/');
|
|
|
|
// Initialize a new session
|
|
session_start();
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
// Includes
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
include './custom/settings/config.php';
|
|
include './custom/settings/settings.php';
|
|
include 'functions.php';
|
|
|
|
//TRANSLATION FILE LOCATION
|
|
if (isset($_GET['language']) && $_GET['language'] !=''){
|
|
//INCLUDE LANGUAGE FILE
|
|
$file_language = './custom/translations/translations_'.strtoupper($_GET['language']).'.php';
|
|
if (file_exists($file_language)){
|
|
include $file_language; //Include the code
|
|
//DEFINE LANGUAGE
|
|
$_SESSION['country_code'] = trim($_GET['language']);
|
|
}
|
|
else {
|
|
include './custom/translations/translations_US.php';
|
|
//DEFINE LANGUAGE
|
|
$_SESSION['country_code'] = language_code;
|
|
}
|
|
}
|
|
elseif(isset($_SESSION['country_code'])){
|
|
$file_language = './custom/translations/translations_'.strtoupper($_SESSION['country_code']).'.php';
|
|
if (file_exists($file_language)){
|
|
include $file_language; //Include the code
|
|
}
|
|
else {
|
|
include './custom/translations/translations_US.php';
|
|
}
|
|
} else {
|
|
include './custom/translations/translations_US.php';
|
|
//DEFINE LANGUAGE
|
|
$_SESSION['country_code'] = language_code;
|
|
}
|
|
|
|
$pdo = pdo_connect_mysql();
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
//LOGIN TO API
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
$data = json_encode(array("clientID" => clientID, "clientsecret" => clientsecret), JSON_UNESCAPED_UNICODE);
|
|
$responses = ioAPIv2('/v2/authorization', $data,'');
|
|
//Decode Payload
|
|
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = '400';}
|
|
$clientsecret = $responses['token'];
|
|
|
|
// Output error variable
|
|
$error = '';
|
|
//error reporting
|
|
if (debug){
|
|
ini_set('display_errors', '1');
|
|
ini_set('display_startup_errors', '1');
|
|
error_reporting(E_ALL);
|
|
}
|
|
|
|
//Age consent session
|
|
if (isset($_POST['age_consent_allow'])){$_SESSION["age_consent"] = 1;}
|
|
|
|
// Banner
|
|
if (isset($_POST['banner_stay'])){$_SESSION["banner"] = 1;}
|
|
if (isset($_POST['banner_move'])){
|
|
session_destroy();
|
|
header('location: '.banner_link.'');
|
|
die();
|
|
}
|
|
|
|
// Define all the routes for all pages
|
|
$url = routes([
|
|
'/' => 'home.php',
|
|
'test' => 'test.php',
|
|
'/about' => 'custom/pages/about.php',
|
|
'/about_morval' => 'custom/pages/about_morval.php',
|
|
'/product/{id}' => 'product.php',
|
|
'/product/{id}/{option_id}' => 'product.php',
|
|
'/products' => 'products.php',
|
|
'/products/{category}' => 'products.php',
|
|
'/products/{category}/{sort}' => 'products.php',
|
|
'/products/{p}/{category}/{sort}' => 'products.php',
|
|
'/myaccount' => 'myaccount.php',
|
|
'/myaccount/{activation_key}' => 'myaccount.php',
|
|
'/myaccount/{tab}' => 'myaccount.php',
|
|
'/download/{id}' => 'download.php',
|
|
'/cart' => 'cart.php',
|
|
'/cart/{remove}' => 'cart.php',
|
|
'/checkout' => 'checkout.php',
|
|
'/placeorder' => 'placeorder.php',
|
|
'/placeorder/{order_id}' => 'placeorder.php',
|
|
'/search/{query}' => 'search.php',
|
|
'/logout' => 'logout.php',
|
|
'/termsandconditions'=> 'custom/pages/termsandconditions.php',
|
|
'/termsandconditions/{download}'=> 'custom/pages/termsandconditions.php',
|
|
'/faq'=> 'custom/pages/faq.php',
|
|
'/privacy'=> 'custom/pages/privacy.php',
|
|
'/privacy/{download}'=> 'custom/pages/privacy.php',
|
|
'/instructions-for-use' => 'custom/pages/faq.php'
|
|
]);
|
|
|
|
// Check if route exists
|
|
if ($url) {
|
|
include $url;
|
|
} else {
|
|
// Page is set to home (home.php) by default, so when the visitor visits that will be the page they see.
|
|
$page = isset($_GET['page']) && file_exists($_GET['page'] . '.php') ? $_GET['page'] : 'home';
|
|
// Include the requested page
|
|
include $page . '.php';
|
|
}
|
|
|
|
|
|
?>
|