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

	//语言包引入
	$m_langpackage=new modulelp;
	
	//变量取得
	if(empty($photo_id)){
		$photo_id=short_check(get_argg('pid'));
		$album_id=short_check(get_argg('aid'));
		$user_id=short_check(get_argg('uid'));
	}
	//数据表定义区
	$t_album = $tablePreStr."album";
	$t_photo = $tablePreStr."photo";

	//功能===========================================================================
	$dbo = new dbex;
	//读写分离定义函数
	dbtarget('r',$dbServs);

	$sql = "select * from $t_photo where photo_id=$photo_id";
	$photo_row = $dbo ->getRow($sql);
	$album_id=$photo_row['album_id'];
	$sql = "select * from $t_album where album_id=$album_id";
	$album_row = $dbo ->getRow($sql);

	//读写分离定义函数
	dbtarget('w',$dbServs);

	//删除照片
	if($album_row['album_skin']==$photo_row['photo_thumb_src']){
		$album_skin = 'uploadfiles/album/logo.jpg';
		$sql = "update $t_album set album_skin = '$album_skin' where album_id=$album_id";
		$dbo -> exeUpdate($sql);
	}
	@unlink('../'.$photo_row['photo_src']);
	@unlink('../'.$photo_row['photo_thumb_src']);

	$sql = "delete from $t_photo where photo_id=$photo_row[photo_id]";
	if($dbo -> exeUpdate($sql)){
		increase_integral($dbo,$int_del_photo,$user_id);
		update_count($dbo,$user_id,"photo_num",-1);
	}

	$sql = "update $t_album set photo_num=photo_num-1 where album_id=$album_id";
	if($dbo -> exeUpdate($sql)){
		echo $m_langpackage->m_del_suc;
	}
?>
