<?php

if (!empty($_GET['del_photo']))
{
	$arr_wall_cache = mysql_fetch_array(mysql_query("SELECT * FROM `wall_cache` WHERE `user_id` = '".$user_id."' LIMIT 1"));
	$del = check($_GET['del_photo']);	

	if (in_array($del, explode("||", substr($arr_wall_cache['photos'], 1, -1))))
	{
		$new_cache = str_replace("|".$del."|", "", $arr_wall_cache['photos']);
		mysql_query("UPDATE `wall_cache` SET `photos` = '".$new_cache."' , count_photos=count_photos-1 WHERE `user_id` = '".$user_id."' LIMIT 1");
		if (file_exists(HOME .'/files/wall/'.$user_id.'/photos/'.$del)) {@unlink(HOME .'/files/wall/'.$user_id.'/photos/'.$del);}
		if (file_exists(HOME .'/files/wall/'.$user_id.'/photos/icons/'.$del)) {@unlink(HOME .'/files/wall/'.$user_id.'/photos/icons/'.$del);}
		if (file_exists(HOME .'/files/wall/'.$user_id.'/photos/mini/'.$del)) {@unlink(HOME .'/files/wall/'.$user_id.'/photos/mini/'.$del);}
		if (file_exists(HOME .'/files/wall/'.$user_id.'/photos/preview/'.$del)) {@unlink(HOME .'/files/wall/'.$user_id.'/photos/preview/'.$del);}
	}
		if ($ajax == 'yes') exit;
		else go(URL.'/wall/upload.php');
}
else if (!empty($_GET['del_audio']))
{
	$arr_wall_cache = mysql_fetch_array(mysql_query("SELECT * FROM `wall_cache` WHERE `user_id` = '".$user_id."' LIMIT 1"));
	$del = abs(intval($_GET['del_audio']));	

	if (in_array($del, explode("||", substr($arr_wall_cache['audio'], 1, -1))))
	{
		$new_cache = str_replace("|".$del."|", "", $arr_wall_cache['audio']);
		mysql_query("UPDATE `wall_cache` SET `audio` = '".$new_cache."' , count_audio=count_audio-1 WHERE `user_id` = '".$user_id."' LIMIT 1");
	}
	
	
	
	else if (!empty($_GET['del_video']))
{
	$arr_wall_cache = mysql_fetch_array(mysql_query("SELECT * FROM `wall_cache` WHERE `user_id` = '".$user_id."' LIMIT 1"));
	$del = abs(intval($_GET['del_video']));	

	if (in_array($del, explode("||", substr($arr_wall_cache['video'], 1, -1))))
	{
		$new_cache = str_replace("|".$del."|", "", $arr_wall_cache['video']);
		mysql_query("UPDATE `wall_cache` SET `video` = '".$new_cache."' , count_video=count_video-1 WHERE `user_id` = '".$user_id."' LIMIT 1");
	}
	
	
}
	
	
	
		if ($ajax == 'yes') exit;
		else go(URL.'/wall/upload.php');
}

?>