<?php



include '../config.php';
if($__testMode==true)
{
	return true;
}

function deleteDir($path) {
    return is_file($path) ?
            @unlink($path) :
            array_map(__FUNCTION__, glob($path.'/*')) == @rmdir($path);
}

if( isset($_GET["PACKID"]) )
{
	$inp = file_get_contents('userdata/containts.json',true);
	$existingPacks=json_decode($inp);
	$packs=json_decode($inp)->sticker_packs;
	$RemoveIndex=0;

	$Newarray = array();
	foreach ($packs as $key => $value) 
	{
		if( number_format ($packs[$key]->identifier) == number_format($_GET["PACKID"]) )
		{
			//$RemoveIndex=$key;
		}
		else
		{
			array_push($Newarray,$packs[$key]);
		}
	}
	$existingPacks->sticker_packs=$Newarray;

	// deleteDir('userdata/'.$_GET["PACKID"] );
	// deleteDir('userdata/'.$_GET["PACKID"].'_small' );
	// deleteDir('userdata/'.$_GET["PACKID"].'_png' );
	// unlink('userdata/'.$_GET["PACKID"].'.zip');


	file_put_contents('userdata/containts.json', json_encode($existingPacks));

}
else
{
	throw new Exception("Pack Id Not found");
}

?>

