require_once ("head.php");
require_once("moderators.php");
require_once("holidays.php");
$photo_id=intval($_GET['photo_id']);
$row=mysql_fetch_array(mysql_query("SELECT * FROM photos WHERE id=$photo_id LIMIT 1"));
if($_SESSION['uid']!=$row['user_id'] and !in_array($_SESSION['uid'],$moderator)){
echo "Это не ваша фотография";
include_once ("bottom.php");
exit;
};
if ($_POST['data_check']==1) {
$message=mysql_real_escape_string(strip_tags($_POST['message']));
mysql_query("DELETE FROM photomagic_tags WHERE id=$photo_id");
mysql_query("DELETE FROM photomagic_tags_goods WHERE id=$photo_id");
$tags_sum=0;
foreach ($tags as $key=>$value){
if (intval($_POST[$key])>0)
{
$tags_sum=$tags_sum+intval($_POST[$key]);
mysql_query("INSERT IGNORE INTO `photomagic_tags` VALUES ($photo_id,".intval($_POST[$key]).")");
}
};
$tags_sum=intval($tags_sum);
$tags_goods_sum=0;
foreach ($tags_goods as $key=>$value){
if (intval($_POST['!'.$key])>0)
{
$tags_goods_sum=$tags_goods_sum+intval($_POST['!'.$key]);
mysql_query("INSERT IGNORE INTO `photomagic_tags_goods` VALUES ($photo_id,".intval($_POST['!'.$key]).")");
}
};
$tags_goods_sum=intval($tags_goods_sum);
$id_photo=intval($_POST['id_photo']);
$status=$row['status'];
//if ($row['status']==-$_SESSION['uid'] and $_POST['del']==0) $status=1;
//if ($row['status']==1 and $_POST['del']==1) $status=-$_SESSION['uid'];
if ($_POST['del']==1) $status=-$_SESSION['uid'];
//echo "status=$status post=".$_POST['del']."row[]status=".$row['status'];
$h=intval($_POST['holidays']);
if ($h<>0)
{
$sq="INSERT IGNORE INTO `holidays` VALUES ($h, $id_photo)";
@mysql_query($sq);
}
@mysql_query("UPDATE `photos` SET tags=$tags_sum, tags_goods=$tags_goods_sum, main_text='$message', status=$status WHERE id=$id_photo LIMIT 1");
if ($status==-$_SESSION['uid']) echo "Фотография будет удалена автоматически ночью, если до этого времени Вы не передумаете.
";
echo "