<?php
if(!defined('IN_MYBB')) die();
function xtra_plgn_info(){
	return array(
		'name'			=> 'XThreads Report Abuse Misc',
		'description'	=> 'Misc for XThreads Report Abuse',
		'website'		=> 'http://mybbhacks.zingaburga.com',
		'author'		=> 'XThreads Mania',
		'authorsite'	=> 'http://mybbhacks.zingaburga.com',
		'version'		=> '1.0',
		'compatibility' => '*',
		'guid'        	=> ''
	);
}
function xtra_plgn_activate(){}
function xtra_plgn_deactivate(){}
$plugins->add_hook('newthread_start','xtra_plgn_run');
$plugins->add_hook('newthread_do_newthread_start','xtra_plgn_run');
function xtra_plgn_run(){
	if($GLOBALS['mybb']->input['fid'] == 2){
		$xtra_aid = intval($GLOBALS['mybb']->input['xthreads_xtra_aid']);
		$xtra_tid = intval($GLOBALS['mybb']->input['xthreads_xtra_tid']);
		$xtra_pid = intval($GLOBALS['mybb']->input['xthreads_xtra_pid']);
		if(!$xtra_aid || !$xtra_tid || !$xtra_pid) error('Invalid Report Abuse','Invalid Report Abuse');
		$query = $GLOBALS['db']->query('SELECT a.aid,p.pid,p.tid
			FROM '.TABLE_PREFIX.'attachments a
			LEFT JOIN '.TABLE_PREFIX.'posts p ON (p.pid=a.pid)
			WHERE aid='.$xtra_aid.'
			LIMIT 0,1
		');
		$caid = $GLOBALS['db']->fetch_array($query);
		if($caid['pid'] != $xtra_pid || $caid['tid'] != $xtra_tid || !$caid['aid']) error('Invalid Report Abuse.','Invalid Report Abuse');
	}
}
?>