$buffer = fread($fp, filesize(DIR_FS_BACKUP . $_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'], '..')) { olc_redirect(olc_href_link(FILENAME_BACKUP)); } olc_remove(DIR_FS_BACKUP . '/' . $_GET['file']); if (!$olc_remove_error) { $messageStack->add_session(SUCCESS_BACKUP_DELETED, 'success'); olc_redirect(olc_href_link(FILENAME_BACKUP)); } break; } } // check if the backup directory exists $dir_ok = false; if (is_dir(DIR_FS_BACKUP)) { $dir_ok = true; if (!is_writeable(DIR_FS_BACKUP)) { $messageStack->add(ERROR_BACKUP_DIRECTORY_NOT_WRITEABLE, 'error'); } } else {
function olc_remove($source) { global $messageStack, $olc_remove_error; if (isset($olc_remove_error)) { $olc_remove_error = false; } if (is_dir($source)) { $dir = dir($source); while ($file = $dir->read()) { if ($file != '.' && $file != '..') { if (is_writeable($source . '/' . $file)) { olc_remove($source . '/' . $file); } else { $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source . '/' . $file), 'error'); $olc_remove_error = true; } } } $dir->close(); if (is_writeable($source)) { rmdir($source); } else { $messageStack->add(sprintf(ERROR_DIRECTORY_NOT_REMOVEABLE, $source), 'error'); $olc_remove_error = true; } } else { if (is_writeable($source)) { unlink($source); } else { $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source), 'error'); $olc_remove_error = true; } } }