<?php
// REQUIRE FILES
require_once 'system/general/components/devicedetect/checkdevice.php';
require_once 'system/general/components/country/class.country.php';
require_once 'data/plugins/phpmailer/PHPMailerAutoload.php';
require_once 'system/general/components/license/require.php';
$scriptversion = file_get_contents('system/version.txt', true);
$scriptversion = preg_replace('/\s+/','',$scriptversion);
$countryreg = ip_info("Visitor", "Country");
$fullserverdirectory = dirname(__FILE__);
if (isset($countryreg)){
	$countryreg = $countryreg;
	$country_name = $countryreg;
}else{
	$countryreg = $country_name;
}

if($countryreg == '') {
	$countryreg = "United States";
	$country_name = $countryreg;
}
if(!file_exists('system/configuration.php')){
	header("Location: install.php");
}else {
	include('system/configuration.php');
}
include('system/dbhandle.php');
include('system/security.php');
include('system/functions.php');
include('data/plugins/load.php');
session_start();
include('system/general/language/LoadFile.php');
include("get/cookieref.php");
// * END: REQUIRE FILES

// GETTING IP
$uip = getIP();

if(isset($_GET['hash'])) {
	$hash = $_GET['hash'];
}

// PAGE TO LOAD >> GETTING NAME FROM PHP GET [URL]
$page = $_GET['page'];
		// FIND FILE NAME FROM DATABASE
		if(!isset($page)) {$page = "home";}
		$pagefile3 = "SELECT `filename` FROM `Web_Pages` WHERE `url` = '$page' LIMIT 1";
		if (@mysql_num_rows(mysql_query($pagefile3))!=1) {
  		   $pagefile = "Custom";
		} else {
		   $pagefile2 = mysql_query($pagefile3) or die($pagefile3."<br/><br/>".mysql_error());
			$pagefile = mysql_result($pagefile2, 0);
		}
		// * END: FIND FILE NAME
// * END: PAGE TO LOAD
// PAGE TO LOAD >> GETTING NAME FROM PHP GET [URL]
$pageperformance = $_GET['type'];
if(!isset($pageperformance)) {$pageperformance = "front";}
if($pageperformance == "front") {$type = "frontend";$fileprefix = "Front_";}
if($pageperformance == "back") {$type = "backend";$fileprefix = "Back_";}
if($pageperformance == "short") {$type = "shortend";$fileprefix = "Short_";}
if($pageperformance == "panel") {$type = "panelend";$fileprefix = "Panel_";}
if($pageperformance == "support") {$type = "supportend";$fileprefix = "Support_";}
if($pageperformance == "payments") {$type = "paymentsend";$fileprefix = "Payments_";}
if($pageperformance == "widget") {$type = "widgetend";$fileprefix = "Widget_";}
if($pageperformance == "premium") {$type = "premium";$fileprefix = "Premium_";}
if($pageperformance == "email") {$type = "emailend";$fileprefix = "Email_";}
// * END: PAGE TO LOAD

// IF RESULT == string "found"
if($type == "shortend") {
				$_POST["code"] = $page;
				if (file_exists("system/panels/{$type}/{$fileprefix}AdLoad.php")) {
    				include("system/panels/{$type}/{$fileprefix}AdLoad.php");
				} else {
    				header("Location: f.404");
				}
			}else if($type == "supportend"){
				if (file_exists("system/panels/{$type}/{$fileprefix}{$page}.php")) {
    				include("system/panels/{$type}/{$fileprefix}{$page}.php");
				} else {
    				header("Location: f.404");
				}
			}else if($type == "emailend"){
				$_POST["title"] = $_GET['title'];
				$_POST["html"] = $_GET['html'];
				if (file_exists("system/panels/{$type}/{$fileprefix}Send.php")) {
    				include("system/panels/{$type}/{$fileprefix}Send.php");
				} else {
    				header("Location: f.404");
				}
			}else if($type == "paymentsend"){
				if (file_exists("system/panels/{$type}/{$fileprefix}{$page}.php")) {
    				include("system/panels/{$type}/{$fileprefix}{$page}.php");
				} else {
    				header("Location: f.404");
				}
			}else if($type == "premium"){
				if (file_exists("system/panels/{$type}end/{$fileprefix}{$page}.php")) {
    				$_POST["hash"] = $hash;
    				include("system/panels/{$type}end/{$fileprefix}{$page}.php");
				} else {
    				header("Location: f.404");
				}
			}else if($type == "panelend"){
				if (file_exists("system/panels/{$type}/{$fileprefix}{$page}.php")) {
    				include("system/panels/{$type}/{$fileprefix}{$page}.php");
				} else {
    				header("Location: f.404");
				}
			}else if($type == "backend"){
				if (file_exists("system/panels/{$type}/{$fileprefix}{$page}.php")) {
    				include("system/panels/{$type}/{$fileprefix}{$page}.php");
				} else {
    				header("Location: f.404");
				}
			}else if($type == "widgetend"){
				if (file_exists("system/panels/{$type}/{$fileprefix}{$page}.php")) {
    				$api = $_GET['api'];
					$_POST["api"] = $api;
    				include("system/panels/{$type}/{$fileprefix}{$page}.php");
				} else {
    				header("Location: f.404");
				}
			}else{
				if($pagefile != "custom") {
					include("system/panels/{$type}/{$fileprefix}{$pagefile}.php");
				}else{
					include("system/panels/{$type}/{$fileprefix}{$pagefile}.php?page={$page}");		
				}
			}
// * END: IF
?>
