CMXX - Multisite setup
This commit is contained in:
34
index.php
34
index.php
@@ -4,9 +4,11 @@ define('secure_admin_342642', true);
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
//=====================================
|
||||
//INCLUDE CONSTANTS
|
||||
include dirname(__FILE__).'/settings/config.php';
|
||||
//=====================================
|
||||
|
||||
include dirname(__FILE__).'/settings/config_redirector.php';
|
||||
if (debug && debug_id == $_SESSION['id']){
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
@@ -17,7 +19,10 @@ if (debug && debug_id == $_SESSION['id']){
|
||||
include dirname(__FILE__).'/assets/functions.php';
|
||||
include dirname(__FILE__).'/settings/settings.php';
|
||||
|
||||
//=====================================
|
||||
//TRANSLATION FILE LOCATION
|
||||
//=====================================
|
||||
|
||||
if (isset($_GET['language']) && $_GET['language'] !=''){
|
||||
//INCLUDE LANGUAGE FILE
|
||||
$api_file_language = './settings/translations/translations_'.strtoupper($_GET['language']).'.php';
|
||||
@@ -31,6 +36,9 @@ if (isset($_GET['language']) && $_GET['language'] !=''){
|
||||
//DEFINE LANGUAGE
|
||||
$_SESSION['country_code'] = 'US';
|
||||
}
|
||||
|
||||
//REMOVE FROM GET TO AVOID THAT LANGUAGE IS USED IN GET_VALUES FUNCTION
|
||||
unset($_GET['language']);
|
||||
}
|
||||
elseif(isset($_SESSION['country_code'])){
|
||||
$api_file_language = './settings/translations/translations_'.strtoupper($_SESSION['country_code']).'.php';
|
||||
@@ -45,8 +53,9 @@ elseif(isset($_SESSION['country_code'])){
|
||||
//DEFINE LANGUAGE
|
||||
$_SESSION['country_code'] = 'US';
|
||||
}
|
||||
|
||||
//=====================================
|
||||
// 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'];
|
||||
@@ -54,6 +63,9 @@ $base_url .= '/' . ltrim(substr(str_replace('\\', '/', realpath(__DIR__)), strle
|
||||
define('base_url', rtrim($base_url, '/') . '/');
|
||||
|
||||
|
||||
//=====================================
|
||||
//CHECK USER SESSION
|
||||
//=====================================
|
||||
if (!isset($_SESSION['loggedin'])) {
|
||||
header('location: login.php');
|
||||
die();
|
||||
@@ -65,15 +77,27 @@ if (isset($_GET['page']) && $_GET['page'] == 'logout') {
|
||||
die();
|
||||
}
|
||||
|
||||
// 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'] : 'dashboard';
|
||||
//=====================================
|
||||
//DEFINE WHERE TO SEND THE USER TO. GET first assigned view in the profile if not available use dashboard
|
||||
//=====================================
|
||||
$allowed_views = explode(',',$_SESSION['profile']);
|
||||
$ignoreViews = ['profile','assets','sales'];
|
||||
$allowed_views = findExistingView($allowed_views, 'dashboard', $ignoreViews);
|
||||
|
||||
//=====================================
|
||||
//FORWARD THE USER TO THE CORRECT PAGE
|
||||
//=====================================
|
||||
$page = isset($_GET['page']) && file_exists($_GET['page'] . '.php') ? $_GET['page'] : $allowed_views;
|
||||
|
||||
// Output error variable
|
||||
$error = '';
|
||||
// Include the requested page
|
||||
include $page . '.php';
|
||||
|
||||
//=====================================
|
||||
//debuglog
|
||||
//=====================================
|
||||
|
||||
if (debug){
|
||||
$message = $date.';'.json_encode($_GET).';'.$_SESSION['username'];
|
||||
debuglog($message);
|
||||
|
||||
Reference in New Issue
Block a user