Fix download css see #7893

1.10.x
Julio 10 years ago
parent 8c47a8c719
commit 26005cf284
  1. 10
      main/admin/settings.lib.php
  2. 9
      main/course_info/download.php

@ -349,15 +349,17 @@ function handle_stylesheets()
}
if (isset($_POST['download'])) {
$arch = api_get_path(SYS_ARCHIVE_PATH).$safe_style_dir.'.zip';
$dir = api_get_path(SYS_CODE_PATH).'css/'.$safe_style_dir;
$dir = api_get_path(SYS_CSS_PATH).'themes/'.$safe_style_dir;
if (is_dir($dir)) {
$zip = new PclZip($arch);
// Remove path prefix except the style name and put file on disk
$zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($safe_style_dir)));
//@TODO: use more generic script to download.
$str = '<a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '">'.get_lang('ClickHereToDownloadTheFile').'</a>';
Display::display_normal_message($str, false);
} else {
Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning'));
}
//@TODO: use more generic script to download.
$str = '<a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '">'.get_lang('ClickHereToDownloadTheFile').'</a>';
Display::display_normal_message($str,false);
}
}

@ -40,14 +40,7 @@ if (empty($content_type)) {
}
if (Security::check_abs_path($archive_path.$archive_file, $archive_path)) {
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: public');
header('Pragma: no-cache');
header('Content-Type: '.$content_type);
header('Content-Length: '.filesize($archive_path.$archive_file));
header('Content-Disposition: attachment; filename='.$archive_file);
readfile($archive_path.$archive_file);
DocumentManager::file_send_for_download($archive_path.$archive_file, true, $archive_file);
exit;
} else {
api_not_allowed(true);

Loading…
Cancel
Save