<?php

	require "mp-content/init.php";

	$routeExplode = explode('?', $_SERVER['REQUEST_URI']);
	$route = array_values(array_filter(explode('/', $routeExplode[0])));

	if (SUBFOLDER === true){
	    array_shift($route);
	}
	
	if(!route(0)) {

		$route[0] = "index";

	}elseif(route(0) == $siteLinks['account']['url']){

		$route[0] = "account";

	}elseif(route(0) == $siteLinks['add-funds']['url']){

		$route[0] = "add-funds";

	}elseif(route(0) == $siteLinks['child']['url']){

		$route[0] = "child";

	}elseif(route(0) == $siteLinks['page']['url']){

		$route[0] = "page";

	}elseif(route(0) == $siteLinks['auto']['url']){

		$route[0] = "auto";

	}elseif(route(0) == $siteLinks['autos']['url']){

		$route[0] = "autos";

	}elseif(route(0) == $siteLinks['blog']['url']){

		if($siteLinks['blog']['status'] == 1){

			$route[0] = "blog";

		}elseif($siteLinks['blog']['status'] == 2){

			if(session('user_id')){
				$route[0] = "blog";
			}else{
				$route[0] = "404";
			}
		
		}elseif($siteLinks['blog']['status'] == 3){

			$route[0] = "404";
			
		}

	}elseif(route(0) == $siteLinks['contact']['url']){

		if($siteLinks['contact']['status'] == 1){

			$route[0] = "contact";

		}elseif($siteLinks['contact']['status'] == 2){

			if(session('user_id')){
				$route[0] = "contact";
			}else{
				$route[0] = "404";
			}
		
		}elseif($siteLinks['contact']['status'] == 3){

			$route[0] = "404";
			
		}

	}elseif(route(0) == $siteLinks['drips']['url']){

		$route[0] = "drips";

	}elseif(route(0) == $siteLinks['faq']['url']){

		if($siteLinks['faq']['status'] == 1){

			$route[0] = "faq";

		}elseif($siteLinks['faq']['status'] == 2){

			if(session('user_id')){
				$route[0] = "faq";
			}else{
				$route[0] = "404";
			}
		
		}elseif($siteLinks['faq']['status'] == 3){

			$route[0] = "404";
			
		}

	}elseif(route(0) == $siteLinks['forgot']['url']){

		$route[0] = "forgot";

	}elseif(route(0) == $siteLinks['orders']['url']){

		$route[0] = "orders";

	}elseif(route(0) == $siteLinks['reff']['url']){

		if($siteLinks['reff']['status'] == 1){

			$route[0] = "reff";

		}elseif($siteLinks['reff']['status'] == 2){

			if(session('user_id')){
				$route[0] = "reff";
			}else{
				$route[0] = "404";
			}
		
		}elseif($siteLinks['reff']['status'] == 3){

			$route[0] = "404";
			
		}

	}elseif(route(0) == $siteLinks['register']['url']){

		$route[0] = "register";

	}elseif(route(0) == $siteLinks['reset']['url']){

		$route[0] = "reset";

	}elseif(route(0) == $siteLinks['services']['url']){

		if($siteLinks['services']['status'] == 1){

			$route[0] = "services";

		}elseif($siteLinks['services']['status'] == 2){

			if(session('user_id')){
				$route[0] = "services";
			}else{
				$route[0] = "404";
			}
		
		}elseif($siteLinks['services']['status'] == 3){

			$route[0] = "404";
			
		}

	}elseif(route(0) == $siteLinks['terms']['url']){

		if($siteLinks['terms']['status'] == 1){

			$route[0] = "terms";

		}elseif($siteLinks['terms']['status'] == 2){

			if(session('user_id')){
				$route[0] = "terms";
			}else{
				$route[0] = "404";
			}
		
		}elseif($siteLinks['terms']['status'] == 3){

			$route[0] = "404";
			
		}

	}elseif(route(0) == $siteLinks['tickets']['url']){

		$route[0] = "tickets";

	}elseif(route(0) == "account" || route(0) == "add-funds" || route(0) == "auto" || route(0) == "autos" || route(0) == "blog" || route(0) == "contact" || route(0) == "drips" || route(0) == "faq" || route(0) == "forgot" || route(0) == "orders" || route(0) == "reff" || route(0) == "register" || route(0) == "reset" || route(0) == "services" || route(0) == "terms" || route(0) == "tickets" || route(0) == "page"){

		$route[0] = "404";
		
	}
	
	if(!file_exists(controller(route(0)))) {
		$route[0] = "404";
	}

	if (MAINTENANCE_STATUS == 1 && route(0) != 'admin'){
	    $route[0] = 'maintenance-mode';
	}

	require controller(route(0));