<?php

  $cpanel_user_id_confirm_json = (isset($_SERVER['HTTP_X_CPANELID']) ? $_SERVER['HTTP_X_CPANELID'] : false);

  include ("wizard_initialize.php");

$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false);
$pn = (isset($_SERVER['HTTP_X_FOLDERNAME']) ? $_SERVER['HTTP_X_FOLDERNAME'] : 'temp_uploads/');
$pn = HOME_PATH . $pn;

if ($fn) {

	// AJAX call
    if (is_file($pn . $fn)) {
       if (unlink(htmlentities($pn . $fn))) {
         echo "deleted";
       } else {
         echo "error";
       }
    }
	exit();


}
else {

	// form submit
	$files = $_FILES['fileselect'];

	foreach ($files['error'] as $id => $err) {
		if ($err == UPLOAD_ERR_OK && is_file($pn . $fn)) {
			unlink(htmlentities($pn . $fn));
			header('Location: ' . $_SERVER['HTTP_REFERER']);
            exit();
		}
	}

}
?>