public function download($params)
{
if (!is_admin()) {
error('must be admin');
}
if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'memory_limit')) {
ini_set('memory_limit', '512M');
}
if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
set_time_limit(0);
}
if (isset($params['id'])) {
$id = $params['id'];
} elseif (isset($_GET['filename'])) {
$id = $params['filename'];
} elseif (isset($_GET['file'])) {
$id = $params['file'];
}
$id = str_replace('..', '', $id);
if ($id == null) {
return array('error' => 'You have not provided filename to download.');
}
$here = $this->get_bakup_location();
$filename = $here . $id;
$filename = str_replace('..', '', $filename);
if (!is_file($filename)) {
return array('error' => 'You have not provided a existing filename to download.');
}
$dl = new \Microweber\Utils\Files();
return $dl->download_to_browser($filename);
}