<?php

if (!empty($_GET['del_comm']) && is_numeric($_GET['del_comm']))
{
	$del_comm = abs(intval($_GET['del_comm']));

	if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `photos_comm` WHERE `id` = '".$del_comm."' LIMIT 1"),0) == true)
	{
		$arr_del_comm = mysql_fetch_array(mysql_query("SELECT * FROM `photos_comm` WHERE `id` = '".$del_comm."' LIMIT 1"));
		
		if ($user_id == $arr_del_comm['user_id'] or $user_id == $arr_photo['user_id'])
		{
		mysql_query("DELETE FROM `photos_comm` WHERE `id` = '".$del_comm."'");
		mysql_query("UPDATE `photos_file` SET comm=comm-1 WHERE `id` = '".$arr_photo['id']."'");
		$arr_photo['comm'] = $arr_photo['comm']-1;
		}
	}
}

?>