summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/pages/downloadimage.php')
-rw-r--r--frontend/pages/downloadimage.php49
1 files changed, 0 insertions, 49 deletions
diff --git a/frontend/pages/downloadimage.php b/frontend/pages/downloadimage.php
deleted file mode 100644
index 2234a10..0000000
--- a/frontend/pages/downloadimage.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-function init_downloadimage() {
- global $S, $request;
- if (!isset($S['user'])) {
- return 'login';
- }
- if (!(isset($request['build']) && strlen($request['build']) == 6 && ctype_alnum($request['build']))) {
- debug('downlaodimage', 'No build or badly formatted build requested');
- return '404';
- }
- $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `id`="'.$request['build'].'"');
- if ($r->rowCount() == 0) {
- debug('downloadimage', 'build not found or not owned by user');
- return '404';
- }
- $build=new sql_build($r->fetch(PDO::FETCH_ASSOC));
- if (!owner_or_admin($build->owner)) {
- debug('downloadimage', 'Permission denied');
- return '404';
- }
- $files=glob(COMPLETED.'/build-'.$build->id.'.*');
- if (count($files)) {
- if (count($files) > 1) {
- debug('downloadimage', 'extraneous file(s) found - don\'t know which to give them');
- return '404';
- }
- $S['file']=$files[0];
- if (!is_readable($S['file'])) {
- debug('downloadimage', 'found file, but no read perms');
- return '404';
- }
- $ext=substr($S['file'], strpos($S['file'], '.'));
- } else {
- debug('downloadimage', 'image file not found');
- return '404';
- }
- $dl=new sql_download($build->id, $S['user']->id, time());
- $dl->write();
- contenttype('application/octet-stream');
- header('Content-Length: '.filesize($S['file']));
- header('Content-Description: File Transfer');
- header('Content-Transfer-Encoding: binary');
- header('Content-Disposition: attachment; filename="'.(isset($build->name) && strlen($build->name)?str_replace('"', '\"', $build->name):'ingenue-'.$build->id).$ext);
-}
-function body_downloadimage() {
- global $S;
- readfile($S['file']);
-}
-?>