$path = stripslashes($_GET['path']);
$parent = dirname($path) . '/';
$redirect = (int) $_GET['redirect'];
$confirmed = (int) $_GET['confirmed'];
$file = basename($path);
$json = array();
// result array
$log_data = array('action' => 'unlink', 'path' => $path);
if ($confirmed !== 1) {
    $tpl = new RFSmarty();
    $path = $_GET['path'];
    $tpl->assign('path', $path);
    $tpl->assign('title', 'Unlink ' . $path);
    $tpl->assign('parent', $parent);
    $tpl->assign('content', 'unlink');
    $tpl->display('_wrapper.tpl');
    exit;
}
// check for a directory argument
if (substr($path, -1) == '/') {
    $json['error'] = true;
    $json['message'] = 'Script refuses to delete a directory.';
    // log this action
    $log_data['result'] = 'failure';
    rf_log($log_data);
    if ($redirect) {
        $_SESSION['errors'][] = $json['message'];
        PSUHTML::redirect($GLOBALS['BASE_URL'] . '/' . $GLOBALS['SSH_HOST'] . ':browse' . $parent);
    } else {
        jsonAndExit($json);
    }