$buffer = fread($fp, filesize(OWP_BACKUP_PATH . '/' . $_GET['file']));
                    fclose($fp);
                    header('Content-type: application/x-octet-stream');
                    header('Content-disposition: attachment; filename=' . $_GET['file']);
                    echo $buffer;
                    exit;
                }
            } else {
                $messageStack->add(ERROR_DOWNLOAD_LINK_NOT_ACCEPTABLE, 'error');
            }
            break;
        case 'deleteconfirm':
            if (strstr($_GET['file'], '..')) {
                owpRedirect(owpLink($owpFilename['backup']));
            }
            owpRemove(OWP_BACKUP_PATH . '/' . $_GET['file']);
            if (!$owpRemoveError) {
                $messageStack->add_session(SUCCESS_BACKUP_DELETED, 'success');
                owpRedirect(owpLink($owpFilename['backup']));
            }
            break;
    }
}
// check if the backup directory exists
$dir_ok = false;
if (is_dir(owpGetLocalPath(OWP_BACKUP_PATH))) {
    $dir_ok = true;
    if (!is_writeable(owpGetLocalPath(OWP_BACKUP_PATH))) {
        $messageStack->add(ERROR_BACKUP_DIRECTORY_NOT_WRITEABLE, 'error');
    }
} else {
function owpRemove($source)
{
    global $messageStack, $owpRemoveError;
    if (isset($owpRemoveError)) {
        $owpRemoveError = false;
    }
    if (is_dir($source)) {
        $dir = dir($source);
        while ($file = $dir->read()) {
            if ($file != '.' && $file != '..') {
                if (is_writeable($source . '/' . $file)) {
                    owpRemove($source . '/' . $file);
                } else {
                    $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source . '/' . $file), 'error');
                    $owpRemoveError = true;
                }
            }
        }
        $dir->close();
        if (is_writeable($source)) {
            rmdir($source);
        } else {
            $messageStack->add(sprintf(ERROR_DIRECTORY_NOT_REMOVEABLE, $source), 'error');
            $owpRemoveError = true;
        }
    } else {
        if (is_writeable($source)) {
            unlink($source);
        } else {
            $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source), 'error');
            $owpRemoveError = true;
        }
    }
}
    $current_path = OWP_ROOT_PATH;
}
if (!ereg('^' . OWP_ROOT_PATH, $current_path)) {
    $current_path = OWP_ROOT_PATH;
}
if ($_GET['action']) {
    switch ($_GET['action']) {
        case 'reset':
            $_SESSION['current_path'] = OWP_ROOT_PATH;
            owpRedirect(owpLink($owpFilename['file_manager']));
            break;
        case 'deleteconfirm':
            if (strstr($_GET['info'], '..')) {
                owpRedirect(owpLink($owpFilename['file_manager']));
            }
            owpRemove($current_path . '/' . $_GET['info']);
            if (!$owpRemoveError) {
                owpRedirect(owpLink($owpFilename['file_manager']));
            }
            break;
        case 'insert':
            if (mkdir($current_path . '/' . $_POST['folder_name'], 0777)) {
                owpRedirect(owpLink($owpFilename['file_manager'], 'info=' . urlencode($_POST['folder_name'])));
            }
            break;
        case 'save':
            if ($fp = fopen($current_path . '/' . $_POST['filename'], 'w+')) {
                fputs($fp, stripslashes($_POST['file_contents']));
                fclose($fp);
                owpRedirect(owpLink($owpFilename['file_manager'], 'info=' . urlencode($_POST['filename'])));
            }