*/ class DirectDownloadPlugin extends VGPlugin { function __construct() { global $conf; $this->register_action('directdownload'); } function action($action) { if ($action === 'directdownload') { $project = validate_project($_REQUEST['p']); $hash = validate_hash($_REQUEST['h']); if (isset($_REQUEST['f'])) { $path = $_REQUEST['f']; $infos=git_get_path_info($project,$hash,$path); if (count($infos)!=1) { die('Invalid path'); } $hash=$infos[0]['hash']; $name=$infos[0]['name']; } else { $name = $_REQUEST['n']; } header('Content-type: application/octet-stream'); header("Content-Disposition: attachment; filename=$name"); run_git_passthru($project, "cat-file blob $hash"); die(); } } }