<?php
include('include/autoloader.php');
$id = intval(make_safe(xss_clean($_GET['id'])));
$slug = make_safe(xss_clean($_GET['slug']));
$profile = $general->user($id);
foreach ($profile AS $key=>$value) {
	$smarty->assign('profile_'.$key,$value);
}
$ur = explode('?',curPageURL());
if (count($ur) != 0) {
if (isset($ur[1])) {
parse_str($ur[1],$q);	
}
}
if (isset($q['show']) AND $q['show'] == 'lists') {
$smarty->assign('tab','lists');	
$page = 1;
if (isset($options['theme_user_lists_number'])) {
	$size = $options['theme_user_lists_number'];
} else {
	$size = 24;
}
if (isset($q['page'])){ $page = (int) $q['page']; }
$sqls = "SELECT * FROM lists WHERE user_id='$profile[id]' AND privacy='0'";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
$smarty->assign('total_records',$total_records);
if ($total_records > 0) {
$pagination = new Pagination();
$pagination->setLink("./profile/$id/$slug?show=lists&page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM lists WHERE user_id='$profile[id]' AND privacy='0' ORDER BY create_datetime DESC ".$pagination->getLimitSql();
$qu = $mysqli->query($get);
while ($rows = $qu->fetch_assoc()) {
	$lists[] = $rows;
}
$smarty->assign('lists',$lists);
$smarty->assign('pagi',$pagination->create_links());
}
$smarty->assign('seo_title',$language['lists_by'].' '.$profile['username'].' - '.$options['general_seo_title']);
} else {
$smarty->assign('tab','videos');
$page = 1;
if (isset($options['theme_search_media_number'])) {
	$size = $options['theme_search_media_number'];
} else {
	$size = 24;
}
if (isset($q['page'])){ $page = (int) $q['page']; }
$sqls = "SELECT * FROM media WHERE published='1' AND deleted='0' AND user_id='$profile[id]'";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
$smarty->assign('total_records',$total_records);
if ($total_records > 0) {
$pagination = new Pagination();
$pagination->setLink("./profile/$id/$slug?show=videos&page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM media WHERE published='1' AND deleted='0' AND user_id='$profile[id]' ORDER BY id DESC ".$pagination->getLimitSql();
$qu = $mysqli->query($get);
while ($row = $qu->fetch_assoc()) {
	$media[] = $row;
}
$smarty->assign('media',$media);
$smarty->assign('pagi',$pagination->create_links());
}
$smarty->assign('seo_title',$language['videos_by'].' '.$profile['username'].' - '.$options['general_seo_title']);
}
$smarty->assign('seo_keywords',$options['general_seo_keywords']);
$smarty->assign('seo_description',$options['general_seo_description']);
$smarty->display('profile.html');
?>