<?php
	/* WebWall */
	define("ONLINE", 1);
	$root = dirname( dirname( dirname(__FILE__) ) );
	require_once "$root/core.php";
	define("PROFILE_USER", text_filter(ucfirst(strtolower($_GET["user_profile"])),1), true);
	$data = $engine_session->getuserdata(PROFILE_USER, "*");
	define("PROFILE_STATUS", $data['user_status'], true);
	define("PROFILE_PHOTO", $data['photo'], true);
	define("PROFILE_COVER", $data['cover'], true);
	define("PROFILE_REAL_NAME", $data['real_name'], true);
	define("PROFILE_REAL_SURNAME", $data['real_surname'], true);
	define("PROFILE_LOCAL", $data['localization'], true);
	define("PROFILE_WEB", $data['website'], true);
	define("PROFILE_BIO", $data['bio'], true);
	define("PROFILE_VISIT", $data['visit'], true);
	define("VERIFIED", $data['verified'], true);
	define("POINTS", $data['points'], true);
	define("PROFILE_ANONYMOUS", $data['anonymous_view'], true);
	define("FOLLOW", $engine_session->getuserrelations(PROFILE_USER, "FOLLOW"), true);
	define("FOLLOWERS", $engine_session->getuserrelations(PROFILE_USER, "FOLLOWERS"), true);
	define("GIFTS", $engine_session->getuserdata(PROFILE_USER, "GIFTS"), true);
	define("PROFILE_POSTS", $engine_session->inboxposts(PROFILE_USER), true);

	$user_p = $engine_session->getuserdata(USER_USERNAME, "PHOTO");
	define("USER_PHOTO", $user_p, true);

	if($engine_session->profileuserexists(''.PROFILE_USER.'') != 0) $result["userExists"] = true; 
		else $result["userExists"] = false; 
	if($engine_session->profileaccess(''.PROFILE_USER.'',''.USER_USERNAME.'') == 1) $result["access"] = true; 
		else $result["access"] = false;
	if($engine_session->profileaccess(''.USER_USERNAME.'',''.PROFILE_USER.'') == 1) $allow=1; 
		else $allow=0;
	define("PROFILE_ACCESS", $allow);
	if($engine_session->profilefriend(''.PROFILE_USER.'',''.USER_USERNAME.'') == 1) $result["friend"] = true; 
		else $result["friend"] = false;
	if($engine_session->profilefriend(''.USER_USERNAME.'',''.PROFILE_USER.'') == 1) $friend=1;
		else $friend=0;
	define("PROFILE_FRIENDS", $friend);

	if($data['status'] != 0) $result["ustatus"] = true; 
		else $result["ustatus"] = false;
	if($data['anonymous_view'] == 0 && SESSION_STATUS == false) $result["userView"] = true; 
	 	else $result["userView"] = false;
	$template_session->setparameter("getlastusergifts", $engine_session->getlastusergifts(''.PROFILE_USER.''), true);
	
	if($result["userExists"] != false)
	{
		if(PROFILE_USER == "Css" || PROFILE_USER == "Images" || PROFILE_USER == "Js" || PROFILE_USER == "Administration" || PROFILE_USER == "administration" || PROFILE_USER == "Core")
		{
			header('Location: http://'.SITE_DOMAIN.'/site/error');
		}
		else if($result["ustatus"] != false)
		{
			$template_session->loadhead(''.PROFILE_USER.' - ('.PROFILE_REAL_NAME.' '.PROFILE_REAL_SURNAME.')');
			$template_session->addscroll(10,PROFILE_USER,5);
			$template_session->loadlogo(); 
			$template_session->loadmenu();  
			if($result["userView"] != false || $result["access"] != false)
			{
				$template_session->addline('<center>');
				$template_session->loadtpl("security");
				$template_session->addline('</center>');
			}
			else
			{
				$template_session->loadtpl("profile");
			}
			$template_session->loadtpl("footer");
			$template_session->loadend();
		}
		else
		{
			header('Location: http://'.SITE_DOMAIN.'/site/disabled');
		}
	}
	else
	{
		header('Location: http://'.SITE_DOMAIN.'/site/error');
	}
?>