[ PHPXref.com ] [ Generated: Sun Jul 20 16:25:05 2008 ] [ ACollab 1.2 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> get_file.php (source)

   1  <?php
   2  /****************************************************************************************/
   3  /* ACollab                                                                              */
   4  /****************************************************************************************/
   5  /* Copyright (c) 2002-2004  Adaptive Technology Resource Centre / University of Toronto */
   6  /*                                                                                      */
   7  /* http://atutor.ca/acollab                                                             */
   8  /*                                                                                      */
   9  /* This program is free software. You may redistribute it and/or                        */
  10  /* modify it under the terms of the GNU General Public License                          */
  11  /* as published by the Free Software Foundation; either version 2 of the License,       */
  12  /* or (at your option) any later version.                                               */
  13  /*                                                                                      */
  14  /* This program is distributed in the hope that it will be useful, but                  */
  15  /* WITHOUT ANY WARRANTY; without even the implied warranty of                           */
  16  /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                                 */
  17  /* See the GNU General Public License for more details.                                 */
  18  /*                                                                                      */
  19  /* You may access the GNU General Public License at:                                    */
  20  /* http://www.opensource.org/licenses/gpl-license.php                                   */
  21  /*                                                                                      */
  22  /* You may contact the Adaptive Technology Resource Centre at                           */
  23  /* Robarts Library, University of Toronto                                               */
  24  /* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
  25  /* Further contact information is available at http://www.utoronto.ca/atrc/             */
  26  /****************************************************************************************/
  27  /* Programmer:                                                                          */
  28  /* Joel Kronenberg - ATRC                                                               */
  29  /****************************************************************************************/
  30  // $Id: get_file.php 148 2004-04-21 20:13:25Z joel $
  31  
  32  define('AC_INCLUDE_PATH', 'include/');
  33  
  34  require(AC_INCLUDE_PATH.'vitals.inc.php');
  35  authenticate(USER_CLIENT, USER_GROUP_ADMIN);
  36  
  37  
  38  $mime['ez'] = 'application/andrew-inset';
  39  $mime['hqx'] = 'application/mac-binhex40';
  40  $mime['cpt'] = 'application/mac-compactpro';
  41  $mime['doc'] = 'application/msword';
  42  $mime['bin'] = 'application/octet-stream';
  43  $mime['dms'] = 'application/octet-stream';
  44  $mime['lha'] = 'application/octet-stream';
  45  $mime['lzh'] = 'application/octet-stream';
  46  $mime['exe'] = 'application/octet-stream';
  47  $mime['class'] = 'application/octet-stream';
  48  $mime['oda'] = 'application/oda';
  49  $mime['pdf'] = 'application/pdf';
  50  $mime['ai'] = 'application/postscript';
  51  $mime['eps'] = 'application/postscript';
  52  $mime['ps'] = 'application/postscript';
  53  $mime['rtf'] = 'application/rtf';
  54  $mime['smi'] = 'application/smil';
  55  $mime['smil'] = 'application/smil';
  56  $mime['mif'] = 'application/vnd.mif';
  57  $mime['ppt'] = 'application/vnd.ms-powerpoint';
  58  $mime['slc'] = 'application/vnd.wap.slc';
  59  $mime['sic'] = 'application/vnd.wap.sic';
  60  $mime['wmlc'] = 'application/vnd.wap.wmlc';
  61  $mime['wmlsc'] = 'application/vnd.wap.wmlscriptc';
  62  $mime['bcpio'] = 'application/x-bcpio';
  63  $mime['bz2'] = 'application/x-bzip2';
  64  $mime['vcd'] = 'application/x-cdlink';
  65  $mime['pgn'] = 'application/x-chess-pgn';
  66  $mime['cpio'] = 'application/x-cpio';
  67  $mime['csh'] = 'application/x-csh';
  68  $mime['dcr'] = 'application/x-director';
  69  $mime['dir'] = 'application/x-director';
  70  $mime['dxr'] = 'application/x-director';
  71  $mime['dvi'] = 'application/x-dvi';
  72  $mime['spl'] = 'application/x-futuresplash';
  73  $mime['gtar'] = 'application/x-gtar';
  74  $mime['gz'] = 'application/x-gzip';
  75  $mime['tgz'] = 'application/x-gzip';
  76  $mime['hdf'] = 'application/x-hdf';
  77  $mime['js'] = 'application/x-javascript';
  78  $mime['kwd'] = 'application/x-kword';
  79  $mime['kwt'] = 'application/x-kword';
  80  $mime['ksp'] = 'application/x-kspread';
  81  $mime['kpr'] = 'application/x-kpresenter';
  82  $mime['kpt'] = 'application/x-kpresenter';
  83  $mime['chrt'] = 'application/x-kchart';
  84  $mime['kil'] = 'application/x-killustrator';
  85  $mime['skp'] = 'application/x-koan';
  86  $mime['skd'] = 'application/x-koan';
  87  $mime['skt'] = 'application/x-koan';
  88  $mime['skm'] = 'application/x-koan';
  89  $mime['latex'] = 'application/x-latex';
  90  $mime['nc'] = 'application/x-netcdf';
  91  $mime['cdf'] = 'application/x-netcdf';
  92  $mime['rpm'] = 'application/x-rpm';
  93  $mime['sh'] = 'application/x-sh';
  94  $mime['shar'] = 'application/x-shar';
  95  $mime['swf'] = 'application/x-shockwave-flash';
  96  $mime['sit'] = 'application/x-stuffit';
  97  $mime['sv4cpio'] = 'application/x-sv4cpio';
  98  $mime['sv4crc'] = 'application/x-sv4crc';
  99  $mime['tar'] = 'application/x-tar';
 100  $mime['tcl'] = 'application/x-tcl';
 101  $mime['tex'] = 'application/x-tex';
 102  $mime['texinfo'] = 'application/x-texinfo';
 103  $mime['texi'] = 'application/x-texinfo';
 104  $mime['t'] = 'application/x-troff';
 105  $mime['tr'] = 'application/x-troff';
 106  $mime['roff'] = 'application/x-troff';
 107  $mime['man'] = 'application/x-troff-man';
 108  $mime['me'] = 'application/x-troff-me';
 109  $mime['ms'] = 'application/x-troff-ms';
 110  $mime['ustar'] = 'application/x-ustar';
 111  $mime['src'] = 'application/x-wais-source';
 112  $mime['zip'] = 'application/zip';
 113  $mime['au'] = 'audio/basic';
 114  $mime['snd'] = 'audio/basic';
 115  $mime['mid'] = 'audio/midi';
 116  $mime['midi'] = 'audio/midi';
 117  $mime['kar'] = 'audio/midi';
 118  $mime['mpga'] = 'audio/mpeg';
 119  $mime['mp2'] = 'audio/mpeg';
 120  $mime['mp3'] = 'audio/mpeg';
 121  $mime['aif'] = 'audio/x-aiff';
 122  $mime['aiff'] = 'audio/x-aiff';
 123  $mime['aifc'] = 'audio/x-aiff';
 124  $mime['ram'] = 'audio/x-pn-realaudio';
 125  $mime['rm'] = 'audio/x-pn-realaudio';
 126  $mime['ra'] = 'audio/x-realaudio';
 127  $mime['wav'] = 'audio/x-wav';
 128  $mime['pdb'] = 'chemical/x-pdb';
 129  $mime['xyz'] = 'chemical/x-pdb';
 130  $mime['gif'] = 'image/gif';
 131  $mime['ief'] = 'image/ief';
 132  $mime['jpeg'] = 'image/jpeg';
 133  $mime['jpg'] = 'image/jpeg';
 134  $mime['jpe'] = 'image/jpeg';
 135  $mime['png'] = 'image/png';
 136  $mime['tiff'] = 'image/tiff';
 137  $mime['tif'] = 'image/tiff';
 138  $mime['wbmp'] = 'image/vnd.wap.wbmp';
 139  $mime['ras'] = 'image/x-cmu-raster';
 140  $mime['pnm'] = 'image/x-portable-anymap';
 141  $mime['pbm'] = 'image/x-portable-bitmap';
 142  $mime['pgm'] = 'image/x-portable-graymap';
 143  $mime['ppm'] = 'image/x-portable-pixmap';
 144  $mime['rgb'] = 'image/x-rgb';
 145  $mime['xbm'] = 'image/x-xbitmap';
 146  $mime['xpm'] = 'image/x-xpixmap';
 147  $mime['xwd'] = 'image/x-xwindowdump';
 148  $mime['igs'] = 'model/iges';
 149  $mime['iges'] = 'model/iges';
 150  $mime['msh'] = 'model/mesh';
 151  $mime['mesh'] = 'model/mesh';
 152  $mime['silo'] = 'model/mesh';
 153  $mime['wrl'] = 'model/vrml';
 154  $mime['vrml'] = 'model/vrml';
 155  $mime['css'] = 'text/css';
 156  $mime['asc'] = 'text/plain';
 157  $mime['txt'] = 'text/plain';
 158  $mime['rtx'] = 'text/richtext';
 159  $mime['rtf'] = 'text/rtf';
 160  $mime['sgml'] = 'text/sgml';
 161  $mime['sgm'] = 'text/sgml';
 162  $mime['tsv'] = 'text/tab-separated-values';
 163  $mime['sl'] = 'text/vnd.wap.sl';
 164  $mime['si'] = 'text/vnd.wap.si';
 165  $mime['wml'] = 'text/vnd.wap.wml';
 166  $mime['wmls'] = 'text/vnd.wap.wmlscript';
 167  $mime['etx'] = 'text/x-setext';
 168  $mime['xml'] = 'text/xml';
 169  $mime['mpeg'] = 'video/mpeg';
 170  $mime['mpg'] = 'video/mpeg';
 171  $mime['mpe'] = 'video/mpeg';
 172  $mime['qt'] = 'video/quicktime';
 173  $mime['mov'] = 'video/quicktime';
 174  $mime['avi'] = 'video/x-msvideo';
 175  $mime['movie'] = 'video/x-sgi-movie';
 176  $mime['ice'] = 'x-conference/x-cooltalk';
 177  $mime['html'] = 'text/html';
 178  $mime['htm'] = 'text/html';
 179  
 180  /* manually added: */
 181  $mime['xls'] = 'application/vnd.ms-excel';
 182  
 183  $id        = intval($_GET['id']);
 184  
 185  $sql    = "SELECT file_name, file_size FROM ".TABLE_PREFIX."files_revisions WHERE revision_id=$id";
 186  
 187  if (!$row) {
 188      $result    = mysql_query($sql, $db);
 189      if (!($row = mysql_fetch_array($result))) {
 190          header('Location: drafting/index.php?f='.E_FILE_NOT_FOUND);
 191          exit;
 192      }
 193  }
 194  
 195      $char = substr($id, 0, 1).'/';
 196      if (!file_exists(UPLOAD_DIR.$char.$id)) {
 197          header('Location: drafting/index.php?f='.E_FILE_NOT_FOUND);
 198          exit;
 199      }
 200  
 201  
 202      $ext = pathinfo($row['file_name']);
 203      $ext = $ext['extension'];
 204      if ($ext == '') {
 205          $ext = 'application/octet-stream';
 206      }
 207      header('Content-Type: '.$mime[$ext]);
 208      header('Content-Type: application/force-download');
 209      header('Content-transfer-encoding: binary'); 
 210      header('Content-Length: '.$row['file_size']);
 211      header('Content-Disposition: attachment; filename="'.$row['file_name'].'"');
 212      header('Expires: 0');
 213      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
 214      header('Pragma: public');
 215  
 216      @readfile(UPLOAD_DIR.$char.$id);
 217      exit;
 218  
 219  
 220  
 221  
 222  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]