<?php
require("session_check.php");	
	require("../foundation/aintegral.php");
	
	//语言包引入
	$m_langpackage=new modulelp;
	
	//变量区
	if(empty($subject_id)){
		$subject_id=intval(short_check(get_argg('subject_id')));
		$group_id=intval(short_check(get_argg('group_id')));
		$sendor_id=intval(short_check(get_argg('sendor_id')));
	}
	
	
	//表定义区
	$t_group_subject=$tablePreStr."group_subject";
	$t_group_comment=$tablePreStr."group_subject_comment";
	$t_uploadfile=$tablePreStr."uploadfile";
	$t_group=$tablePreStr."groups";
	
	$dbo = new dbex;
	dbtarget('r',$dbServs);
	
	//删除主题内部的图片
	$sql="select content,group_id from $t_group_subject where subject_id=$subject_id";
	$subject_content=$dbo->getRow($sql);
	$subject_content=$subject_content['content'];
	preg_match_all("/classId=\"\d\"/",$subject_content,$match);
	$match=preg_replace("/[classId=,\"]/",'',$match[0]);
	$group_id=$subject_content['group_id'];
	
	if(!empty($match)){
		$match=join(",",$match);
		$sql="select file_src from $t_uploadfile where id in ($match)";
		$file_src=$dbo->getRs($sql);
		foreach($file_src as $rs){
			unlink($rs['file_src']);
		}
	}
	$dbo = new dbex;
	dbtarget('w',$dbServs);
	
	if(!empty($match)){
		$sql="delete from $t_uploadfile where id in ($match)";
		$dbo->exeUpdate($sql);
	}
	
	$sql="delete from $t_group_subject where subject_id=$subject_id";
	$dbo->exeUpdate($sql);
	
	$sql="update $t_group set subjects_num=subjects_num-1 where group_id=$group_id";
	$dbo->exeUpdate($sql);
	
	$sql="delete from $t_group_comment where subject_id=$subject_id";
	$dbo->exeUpdate($sql);
	
	increase_integral($dbo,$int_del_subject,$sendor_id);
	
	echo $m_langpackage->m_del_suc;
?>