<?php
	require("session_check.php");	
	require("../foundation/aintegral.php");
	require("../foundation/adata_count.php");
	
	
	//语言包引入
	$m_langpackage=new modulelp;
	
	//变量区
	if(empty($blog_id)){
		$blog_id=intval(short_check(get_argg('blog_id')));
		$sendor_id=intval(short_check(get_argg('sendor_id')));
	}
	$dbo = new dbex;
	dbtarget('w',$dbServs);
	
	//数据表定义区
	$t_blog=$tablePreStr."blog";
	$t_uploadfile=$tablePreStr."uploadfile";
	$t_blog_comments=$tablePreStr."blog_comment";
	
	//删除blog内部的图片
	$sql="select log_content from $t_blog where log_id=$blog_id";
	$blog_content=$dbo->getRow($sql);
	$blog_content=$blog_content['log_content'];
	preg_match_all("/classId=\"\d\"/",$blog_content,$match);
	$match=preg_replace("/[classId=,\"]/",'',$match[0]);
	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']);
		}
	}

	if(!empty($match)){
	$sql="delete from $t_uploadfile where id in ($match)";
	$dbo->exeUpdate($sql);
	}

	$sql = "delete from $t_blog where log_id=$blog_id";

	if($dbo->exeUpdate($sql)&&mysql_affected_rows()>0){
		$sql="delete from $t_blog_comments where log_id=$blog_id";
		$dbo->exeUpdate($sql);
	}else{
		echo $m_langpackage->m_del_lose;
	}
	increase_integral($dbo,$int_del_blog,$sendor_id);
	update_count($dbo,$sendor_id,"blog_num",-1);
	//回应信息
	echo $m_langpackage->m_del_suc;
?>