<?php
require("global.php");

if(!$lfjid){
	showerr("你還沒登錄");
}

$lfjdb[money]=get_money($lfjuid);

if($job=="buy"||$action=='buy'){
	$rsdb=$db->get_one("SELECT * FROM {$pre}group WHERE gid='$gid'");
	if(!$rsdb){
		showerr("資料有誤");
	}	
}

if($action=='buy')
{
	if($lfjdb[groupid]==3||$lfjdb[groupid]==4){
		showerr("你是管理員,不可以購買比你低的級別");
	}
	if($lfjdb[money]<$rsdb[levelnum]){
		showerr("你的積分不足$rsdb[levelnum]");
	}
	$lfjdb[C][endtime]=$timestamp+$webdb[groupTime]*3600*24;
	$config=addslashes(serialize($lfjdb[C]));
	$db->query("UPDATE {$pre}memberdata SET config='$config',groupid='$gid' WHERE uid='$lfjuid'");
	add_user($lfjuid,-$rsdb[levelnum]);
	refreshto("$FROMURL","恭喜你,升級succeed",1);
}

 
$query = $db->query("SELECT * FROM {$pre}group WHERE gptype=0 AND gid!=8");
while($rs = $db->fetch_array($query)){
	$listdb[]=$rs;
}

if($lfjdb[C][endtime]&&$lfjdb[groupid]!=8){
	$lfjdb[C][endtime]=date("Y-m-d",$lfjdb[C][endtime]);
	$lfjdb[C][endtime]="截止日期為:{$lfjdb[C][endtime]}，";
}else{
	$lfjdb[C][endtime]='';
}

require(dirname(__FILE__)."/"."head.php");
require(dirname(__FILE__)."/"."template/buygroup.htm");
require(dirname(__FILE__)."/"."foot.php");

?>