<?php
include_once("inc/config.php");
include_once("inc/ftbbsdbclass.php");
include_once("inc/publicfun.php");
include_once("conn.php");
include_once("checkuser.php");
include_once("bbsuser.php");

$userid=intval(get_cookie('clubuser_id'));
$flag=intval($_GET["flag"]);
$id=intval($_GET["id"]);
$page=$_GET["page"];
if ($page==""){
$page=1;
}

$sql="select * from {$tablepre}ftbbs_upload where id=".$id." and blogphoto=1";
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);
$pic=$myrow["upload_pic"];
$photo_name=$myrow["photo_name"];

$sql="delete from {$tablepre}ftbbs_upload where id='".$id."'";
mysql_query($sql);
$sql="update {$tablepre}ftblog_type set totalnum=totalnum-1 where blogtype='".$photo_name."' and totalnum>0 and userid='".$userid."'";
mysql_query($sql);
if (file_exists($pic)){
   unlink($pic);
} 
header("Location:photomanage.php?page=".$page);
?>
