<?php 
	// We check in which language we will work
	if (isset($_SESSION["DATAGLOBAL"][0]) && !empty($_SESSION["DATAGLOBAL"][0])) $C->LANGUAGE = $_SESSION["DATAGLOBAL"][0];

	$this->load_langfile('inside/dashboard.php');
	$this->load_langfile('global/global.php');

	$errored = 0;
	$txterror = '';


	$codeitem = '';
	$typeItem = 0;
	
	if (isset($_POST["c"]) && $_POST["c"]!='') $codeitem = $this->db1->e($_POST["c"]);
	if (isset($_POST["ti"])) $typeItem = $this->db1->e($_POST["ti"]);
	
	if (empty($codeitem)) { $errored = 1; $txterror .= 'Error. '; }		
	
	if ($errored == 1) {
		echo('0: '.$txterror);
	} else {

		switch ($typeItem) {
			case 0:
				$obj = $this->db1->fetch("SELECT * FROM users WHERE code='".$codeitem."' LIMIT 1");
				$D->cover = $obj->cover;
				$D->avatar = $obj->avatar;
				$D->isUserVerified = $obj->verified;
				$D->username = $obj->username;
				$D->num_posts = $obj->num_posts_inwall;
				$D->num_friends = $obj->num_friends;
				$D->nameUser = (empty($obj->firstname) || empty($obj->lastname))?$obj->username:($obj->firstname.' '.$obj->lastname);
				$txtreturn = $this->load_template('__itemCard.php', FALSE);	
				if (empty($obj->cover)) echo('2: '.$txtreturn);
				else echo('1: '.$txtreturn);
				return;
				break;
			case 1:
				$obj = $this->db1->fetch("SELECT pages.*, pages_cat.name as namecategory FROM pages, pages_cat WHERE pages.idsubcategory=pages_cat.idcategory AND code='".$codeitem."' LIMIT 1");
				$D->coverpage = $obj->cover_page;
				$D->avatarpage = $obj->avatar_page;
				$D->verifiedpage = $obj->verified;
				$D->urlpage = $obj->url;
				$D->num_posts_page = $obj->num_posts;
				$D->num_likes_page = $obj->num_likes;
				$D->titlepage = stripslashes($obj->title);
				$D->namecategory = stripslashes($obj->namecategory);
				$txtreturn = $this->load_template('__itemCardPage.php', FALSE);	
				if (empty($obj->cover_page)) echo('2: '.$txtreturn);
				else echo('1: '.$txtreturn);
				return;			
				break;
			case 2:
				$obj = $this->db1->fetch("SELECT groups.* FROM groups WHERE code='".$codeitem."' LIMIT 1");
				$D->covergroup = $obj->cover_group;
				$D->urlgroup = $obj->url;
				$D->num_posts_group = $obj->num_posts;
				$D->num_members = $obj->num_members;
				$D->namegroup = stripslashes($obj->name_group);
				$txtreturn = $this->load_template('__itemCardGroup.php', FALSE);	
				if (empty($obj->cover_group)) echo('2: '.$txtreturn);
				else echo('1: '.$txtreturn);
				return;			
				break;
		}	
	}
?>