1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
4 require_once 'MtrackWeb.php';
6 class MTrackWeb_Attachment extends MTrackWeb
10 return parent::getAuth();
16 require_once 'MTrack/Attachment.php';
19 $vars = explode('/', $pi);
20 //array_shift($vars); // as our version does not add '/'
21 $filename = array_pop($vars);
22 $cid = array_pop($vars);
23 $object = join('/', $vars);
25 MTrackACL::requireAllRights($object, 'read');
32 object = ? and cid = ? and filename = ?',
33 $object, $cid, $filename);
36 throw new Exception("Image not found");
38 $row = array_shift($q->fetchAll());
39 $filename = basename($filename);
40 header("Pragma: public");
42 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
43 header('Cache-Control: private', false);
44 $path = MTrackAttachment::local_path($row['hash']);
45 require_once 'File/MimeType.php';
46 $y = new File_MimeType();
47 $mimetype = $y->fromFilename($filename);
49 header("Content-Type: $mimetype");
51 list($major) = explode('/', $mimetype, 2);
52 if ($major == 'image' || $major == 'text') {
57 header("Content-Disposition: $disp; filename=\"$filename\"");
58 header('Content-Transfer-Encoding: binary');
59 header("Content-Length: $row[size]");