<?php
if(!defined('IN_PORTAL')){
	die('Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.');
}

$xtdldfid = 1;// Forum ID for XThreads Downloads
$xtdldlimit = 3;// Number of images to be displayed
$xtdlddim = '320x240';// Thumbs dimension to be displayed
$xtdldscr = 'fscr';// Screenshot XThreads fields key
$query = $db->query('
	SELECT t.tid, t.subject, a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename, a.thumbs
	FROM '.TABLE_PREFIX.'threads t
	LEFT JOIN '.TABLE_PREFIX.'xtattachments a ON (a.tid=t.tid)
	WHERE t.fid='.intval($xtdldfid).' AND t.visible=1 AND t.closed NOT LIKE "moved|%" AND a.field="'.$db->escape_string($xtdldscr).'"
	ORDER BY t.dateline DESC
	LIMIT 0,'.intval($xtdldlimit).'
');
if($db->num_rows($query)){
	while($xtdld = $db->fetch_array($query)){
		if($xtdld['thumbs']) $xtdld['thumbs'] = unserialize($xtdld['thumbs']);
		$xtdld_images_image .= '<div style="text-align: center;"><a href="'.get_thread_link($xtdld['tid']).'"><img src="'.xthreads_get_xta_url($xtdld,$xtdlddim).'" alt="'.htmlspecialchars_uni($xtdld['subject']).'" title="'.htmlspecialchars_uni($xtdld['subject']).'" style="margin: 3px; padding: 3px; border: 1px solid #ADCBE7;" width="'.$xtdld['thumbs'][$xtdlddim]['w'].'" height="'.$xtdld['thumbs'][$xtdlddim]['h'].'" /></a><br /><strong><a href="'.get_thread_link($xtdld['tid']).'">'.htmlspecialchars_uni($xtdld['subject']).'</a></strong></div><br />';
	}
	echo $xtdld_images_image;
}
?>