<?php
/**
 *	[网盘虚拟附件--免跳转下载(threed_pan.{modulename})] (C)2014-2015 Powered by www.dzfuns.com.
 *	Version: 商业版  By:QQ 3035511681
 *	Date: 2014-12-3 21:54
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
global $_G;
$urlinfo=$_GET['url'];
$urlinfo=base64_decode($urlinfo);
$urlinfo=explode("|",$urlinfo);
$pan_srl=$urlinfo[1];
$pan_type=$urlinfo[0];
$tid=$urlinfo[2];
$buycount=DB::result_first('SELECT count(1) FROM '.DB::table('threed_pan').' WHERE buy_tid='.$tid.' and buy_uid = '.$_G['uid']);
$pan_srlname=$_GET['name'];
$pan_kofen=$_G['cache']['plugin']['threed_pan']['thd_koufen'];
$pan_user=unserialize($_G['cache']['plugin']['threed_pan']["thd_user"]);
$pan_auth=DB::result_first("SELECT authorid FROM ".DB::table('forum_thread')." WHERE tid=".$tid);
$navtitle =$pan_srlname.lang('plugin/threed_pan', 'downld1');
$panbox_w=array(0,700,700,700,700);//下载框的长度
$panbox_h=array(0,390,100,400,400);//下载框的高度
$panbox_x=array(0,-30,40,-130,50);//X方向偏移距离
$panbox_y=array(0,-80,-120,-130,40);//Y方面偏移距离
$iframe_w=$panbox_w[$pan_type]-$panbox_x[$pan_type];
$iframe_h=$panbox_h[$pan_type]-$panbox_y[$pan_type];

if($_GET['formhash']!=FORMHASH)showmessage(lang('plugin/threed_pan', 'downld2'),  array(), array(), array('alert' => 'error'));
if($_G['uid']==0){
		showmessage(lang('plugin/threed_pan', 'downld3'), '', array(), array('alert' => 'info'));
	}else{
if((!in_array($_G[groupid], $pan_user))&&$pan_kofen&&$buycount==0&&$pan_auth!=$_G['uid']){
	$user_creditnum=DB::result_first("select extcredits".$_G['setting']['creditstransextra'][1]." from ".DB::table('common_member_count')." where uid=".$_G['uid']);
	if($user_creditnum<$pan_kofen){
	showmessage($_G['cache']['plugin']['threed_pan']['thd_credit'],  array(), array(), array('alert' => 'info'));
	}
	$buy_credit = $_G['setting']['creditstransextra'][1];
	$buy_creditname = $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'];
		
		$svaebuy = array(
			'buy_uid' => $_G['uid'],
			'buy_tid' => $tid,
			'buy_info' => lang('plugin/threed_pan', 'downld7').$pan_kofen.$buy_creditname,
			'buy_time' => $_G['timestamp']
		);
		$id = C::t('#threed_pan#threed_pan')->insert($svaebuy, true);
		if($id){
	DB::query('update '.DB::table('common_member_count').' set extcredits'.$buy_credit.'=extcredits'.$buy_credit.'-'.$pan_kofen.' where uid='.$_G['uid']);
	$kofen_info =$buy_creditname.'-'.$pan_kofen;			
	$kofen_info.=','.$_G['cache']['plugin']['threed_pan']['thd_downld'];
		}else{
			showmessage(lang('plugin/threed_pan', 'downld2'),  array(), array(), array('alert' => 'error'));
		}
}else{
	$kofen_info=$_G['cache']['plugin']['threed_pan']['thd_downld'];
}
include template('diy:downld', 0, 'source/plugin/threed_pan/template');
	}
//TODO - Insert your code here 
?>