<?php
	require("session_check.php");	
	require("../foundation/aintegral.php");
	require("../foundation/adata_count.php");

	//语言包引入
	$m_langpackage=new modulelp;
	
	//变量取得
	if(empty($album_id)){
		$album_id=short_check(get_argg('aid'));
		$user_id=short_check(get_argg('uid'));
	}
	//删除相册功能
	//数据表定义区
	$t_album = $tablePreStr."album";
	$t_photo = $tablePreStr."photo";
	$t_photo_comment = $tablePreStr."photo_comment";
	$t_album_comment = $tablePreStr."album_comment";

	$dbo = new dbex;
	//读写分离定义方法
	dbtarget('r',$dbServs);
	$sql="select * from $t_photo where album_id=$album_id";
	$photo_rs = $dbo -> getRs($sql);
	dbtarget('w',$dbServs);
	foreach($photo_rs as $val){
		@unlink('../'.$val['photo_src']);
		@unlink('../'.$val['photo_thumb_src']);
		increase_integral($dbo,$int_del_photo,$user_id);
		update_count($dbo,$user_id,"photo_num",-1);
		//删除照片相关评论
		$photo_id = $val['photo_id'];
		$sql = "delete from $t_photo_comment where photo_id =$photo_id";
		$dbo -> exeUpdate($sql);
	}

	//删除相册有关照片
	$sql = "delete from $t_photo where album_id=$album_id";
	$dbo -> exeUpdate($sql);

	//删除相册相关评论
	$sql = "delete from $t_album_comment where album_id=$album_id";
	$dbo -> exeUpdate($sql);

	//删除相册
	$sql="delete from $t_album where album_id=$album_id";
	if($dbo -> exeUpdate($sql)){
		echo $m_langpackage->m_del_suc;
	}
	
?>