Location: PHPKode > projects > PluggedOut CMS > document_fetch.php
<?php

include "./lib/config.php";
include "./lib/database.php";


$mimetypes[".3dm"]="x-world/x-3dmf";
$mimetypes[".3dmf"]="x-world/x-3dmf";
$mimetypes[".a"]="application/octet-stream";
$mimetypes[".aab"]="application/x-authorware-bin";
$mimetypes[".aam"]="application/x-authorware-map";
$mimetypes[".aas"]="application/x-authorware-seg";
$mimetypes[".abc"]="text/vnd.abc";
$mimetypes[".acgi"]="text/html";
$mimetypes[".afl"]="video/animaflex";
$mimetypes[".ai"]="application/postscript";
$mimetypes[".aif"]="audio/aiff";
$mimetypes[".aif"]="audio/x-aiff";
$mimetypes[".aifc"]="audio/aiff";
$mimetypes[".aifc"]="audio/x-aiff";
$mimetypes[".aiff"]="audio/aiff";
$mimetypes[".aiff"]="audio/x-aiff";
$mimetypes[".aim"]="application/x-aim";
$mimetypes[".aip"]="text/x-audiosoft-intra";
$mimetypes[".ani"]="application/x-navi-animation";
$mimetypes[".aos"]="application/x-nokia-9000-communicator-add-on-software";
$mimetypes[".aps"]="application/mime";
$mimetypes[".arc"]="application/octet-stream";
$mimetypes[".arj"]="application/arj";
$mimetypes[".arj"]="application/octet-stream";
$mimetypes[".art"]="image/x-jg";
$mimetypes[".asf"]="video/x-ms-asf";
$mimetypes[".asm"]="text/x-asm";
$mimetypes[".asp"]="text/asp";
$mimetypes[".asx"]="application/x-mplayer2";
$mimetypes[".asx"]="video/x-ms-asf";
$mimetypes[".asx"]="video/x-ms-asf-plugin";
$mimetypes[".au"]="audio/basic";
$mimetypes[".au"]="audio/x-au";
$mimetypes[".avi"]="application/x-troff-msvideo";
$mimetypes[".avi"]="video/avi";
$mimetypes[".avi"]="video/msvideo";
$mimetypes[".avi"]="video/x-msvideo";
$mimetypes[".avs"]="video/avs-video";
$mimetypes[".bcpio"]="application/x-bcpio";
$mimetypes[".bin"]="application/mac-binary";
$mimetypes[".bin"]="application/macbinary";
$mimetypes[".bin"]="application/octet-stream";
$mimetypes[".bin"]="application/x-binary";
$mimetypes[".bin"]="application/x-macbinary";
$mimetypes[".bm"]="image/bmp";
$mimetypes[".bmp"]="image/bmp";
$mimetypes[".bmp"]="image/x-windows-bmp";
$mimetypes[".boo"]="application/book";
$mimetypes[".book"]="application/book";
$mimetypes[".boz"]="application/x-bzip2";
$mimetypes[".bsh"]="application/x-bsh";
$mimetypes[".bz"]="application/x-bzip";
$mimetypes[".bz2"]="application/x-bzip2";
$mimetypes[".c"]="text/plain";
$mimetypes[".c"]="text/x-c";
$mimetypes[".c++"]="text/plain";
$mimetypes[".cat"]="application/vnd.ms-pki.seccat";
$mimetypes[".cc"]="text/plain";
$mimetypes[".cc"]="text/x-c";
$mimetypes[".ccad"]="application/clariscad";
$mimetypes[".cco"]="application/x-cocoa";
$mimetypes[".cdf"]="application/cdf";
$mimetypes[".cdf"]="application/x-cdf";
$mimetypes[".cdf"]="application/x-netcdf";
$mimetypes[".cer"]="application/pkix-cert";
$mimetypes[".cer"]="application/x-x509-ca-cert";
$mimetypes[".cha"]="application/x-chat";
$mimetypes[".chat"]="application/x-chat";
$mimetypes[".class"]="application/java";
$mimetypes[".class"]="application/java-byte-code";
$mimetypes[".class"]="application/x-java-class";
$mimetypes[".com"]="application/octet-stream";
$mimetypes[".com"]="text/plain";
$mimetypes[".conf"]="text/plain";
$mimetypes[".cpio"]="application/x-cpio";
$mimetypes[".cpp"]="text/x-c";
$mimetypes[".cpt"]="application/mac-compactpro";
$mimetypes[".cpt"]="application/x-compactpro";
$mimetypes[".cpt"]="application/x-cpt";
$mimetypes[".crl"]="application/pkcs-crl";
$mimetypes[".crl"]="application/pkix-crl";
$mimetypes[".crt"]="application/pkix-cert";
$mimetypes[".crt"]="application/x-x509-ca-cert";
$mimetypes[".crt"]="application/x-x509-user-cert";
$mimetypes[".csh"]="application/x-csh";
$mimetypes[".csh"]="text/x-script.csh";
$mimetypes[".css"]="application/x-pointplus";
$mimetypes[".css"]="text/css";
$mimetypes[".cxx"]="text/plain";
$mimetypes[".dcr"]="application/x-director";
$mimetypes[".deepv"]="application/x-deepv";
$mimetypes[".def"]="text/plain";
$mimetypes[".der"]="application/x-x509-ca-cert";
$mimetypes[".dif"]="video/x-dv";
$mimetypes[".dir"]="application/x-director";
$mimetypes[".dl"]="video/dl";
$mimetypes[".dl"]="video/x-dl";
$mimetypes[".doc"]="application/msword";
$mimetypes[".dot"]="application/msword";
$mimetypes[".dp"]="application/commonground";
$mimetypes[".drw"]="application/drafting";
$mimetypes[".dump"]="application/octet-stream";
$mimetypes[".dv"]="video/x-dv";
$mimetypes[".dvi"]="application/x-dvi";
$mimetypes[".dwf"]="drawing/x-dwf(old)";
$mimetypes[".dwf"]="model/vnd.dwf";
$mimetypes[".dwg"]="application/acad";
$mimetypes[".dwg"]="image/vnd.dwg";
$mimetypes[".dwg"]="image/x-dwg";
$mimetypes[".dxf"]="application/dxf";
$mimetypes[".dxf"]="image/vnd.dwg";
$mimetypes[".dxf"]="image/x-dwg";
$mimetypes[".dxr"]="application/x-director";
$mimetypes[".el"]="text/x-script.elisp";
$mimetypes[".elc"]="application/x-bytecode.elisp(compiledelisp)";
$mimetypes[".elc"]="application/x-elc";
$mimetypes[".env"]="application/x-envoy";
$mimetypes[".eps"]="application/postscript";
$mimetypes[".es"]="application/x-esrehber";
$mimetypes[".etx"]="text/x-setext";
$mimetypes[".evy"]="application/envoy";
$mimetypes[".evy"]="application/x-envoy";
$mimetypes[".exe"]="application/octet-stream";
$mimetypes[".f"]="text/plain";
$mimetypes[".f"]="text/x-fortran";
$mimetypes[".f77"]="text/x-fortran";
$mimetypes[".f90"]="text/plain";
$mimetypes[".f90"]="text/x-fortran";
$mimetypes[".fdf"]="application/vnd.fdf";
$mimetypes[".fif"]="application/fractals";
$mimetypes[".fif"]="image/fif";
$mimetypes[".fli"]="video/fli";
$mimetypes[".fli"]="video/x-fli";
$mimetypes[".flo"]="image/florian";
$mimetypes[".flx"]="text/vnd.fmi.flexstor";
$mimetypes[".fmf"]="video/x-atomic3d-feature";
$mimetypes[".for"]="text/plain";
$mimetypes[".for"]="text/x-fortran";
$mimetypes[".fpx"]="image/vnd.fpx";
$mimetypes[".fpx"]="image/vnd.net-fpx";
$mimetypes[".frl"]="application/freeloader";
$mimetypes[".funk"]="audio/make";
$mimetypes[".g"]="text/plain";
$mimetypes[".g3"]="image/g3fax";
$mimetypes[".gif"]="image/gif";
$mimetypes[".gl"]="video/gl";
$mimetypes[".gl"]="video/x-gl";
$mimetypes[".gsd"]="audio/x-gsm";
$mimetypes[".gsm"]="audio/x-gsm";
$mimetypes[".gsp"]="application/x-gsp";
$mimetypes[".gss"]="application/x-gss";
$mimetypes[".gtar"]="application/x-gtar";
$mimetypes[".gz"]="application/x-compressed";
$mimetypes[".gz"]="application/x-gzip";
$mimetypes[".gzip"]="application/x-gzip";
$mimetypes[".gzip"]="multipart/x-gzip";
$mimetypes[".h"]="text/plain";
$mimetypes[".h"]="text/x-h";
$mimetypes[".hdf"]="application/x-hdf";
$mimetypes[".help"]="application/x-helpfile";
$mimetypes[".hgl"]="application/vnd.hp-hpgl";
$mimetypes[".hh"]="text/plain";
$mimetypes[".hh"]="text/x-h";
$mimetypes[".hlb"]="text/x-script";
$mimetypes[".hlp"]="application/hlp";
$mimetypes[".hlp"]="application/x-helpfile";
$mimetypes[".hlp"]="application/x-winhelp";
$mimetypes[".hpg"]="application/vnd.hp-hpgl";
$mimetypes[".hpgl"]="application/vnd.hp-hpgl";
$mimetypes[".hqx"]="application/binhex";
$mimetypes[".hqx"]="application/binhex4";
$mimetypes[".hqx"]="application/mac-binhex";
$mimetypes[".hqx"]="application/mac-binhex40";
$mimetypes[".hqx"]="application/x-binhex40";
$mimetypes[".hqx"]="application/x-mac-binhex40";
$mimetypes[".hta"]="application/hta";
$mimetypes[".htc"]="text/x-component";
$mimetypes[".htm"]="text/html";
$mimetypes[".html"]="text/html";
$mimetypes[".htmls"]="text/html";
$mimetypes[".htt"]="text/webviewhtml";
$mimetypes[".htx"]="text/html";
$mimetypes[".ice"]="x-conference/x-cooltalk";
$mimetypes[".ico"]="image/x-icon";
$mimetypes[".idc"]="text/plain";
$mimetypes[".ief"]="image/ief";
$mimetypes[".iefs"]="image/ief";
$mimetypes[".iges"]="application/iges";
$mimetypes[".iges"]="model/iges";
$mimetypes[".igs"]="application/iges";
$mimetypes[".igs"]="model/iges";
$mimetypes[".ima"]="application/x-ima";
$mimetypes[".imap"]="application/x-httpd-imap";
$mimetypes[".inf"]="application/inf";
$mimetypes[".ins"]="application/x-internett-signup";
$mimetypes[".ip"]="application/x-ip2";
$mimetypes[".isu"]="video/x-isvideo";
$mimetypes[".it"]="audio/it";
$mimetypes[".iv"]="application/x-inventor";
$mimetypes[".ivr"]="i-world/i-vrml";
$mimetypes[".ivy"]="application/x-livescreen";
$mimetypes[".jam"]="audio/x-jam";
$mimetypes[".jav"]="text/plain";
$mimetypes[".jav"]="text/x-java-source";
$mimetypes[".java"]="text/plain";
$mimetypes[".java"]="text/x-java-source";
$mimetypes[".jcm"]="application/x-java-commerce";
$mimetypes[".jfif"]="image/jpeg";
$mimetypes[".jfif"]="image/pjpeg";
$mimetypes[".jfif-tbnl"]="image/jpeg";
$mimetypes[".jpe"]="image/jpeg";
$mimetypes[".jpe"]="image/pjpeg";
$mimetypes[".jpeg"]="image/jpeg";
$mimetypes[".jpeg"]="image/pjpeg";
$mimetypes[".jpg"]="image/jpeg";
$mimetypes[".jpg"]="image/pjpeg";
$mimetypes[".jps"]="image/x-jps";
$mimetypes[".js"]="application/x-javascript";
$mimetypes[".jut"]="image/jutvision";
$mimetypes[".kar"]="audio/midi";
$mimetypes[".kar"]="music/x-karaoke";
$mimetypes[".ksh"]="application/x-ksh";
$mimetypes[".ksh"]="text/x-script.ksh";
$mimetypes[".la"]="audio/nspaudio";
$mimetypes[".la"]="audio/x-nspaudio";
$mimetypes[".lam"]="audio/x-liveaudio";
$mimetypes[".latex"]="application/x-latex";
$mimetypes[".lha"]="application/lha";
$mimetypes[".lha"]="application/octet-stream";
$mimetypes[".lha"]="application/x-lha";
$mimetypes[".lhx"]="application/octet-stream";
$mimetypes[".list"]="text/plain";
$mimetypes[".lma"]="audio/nspaudio";
$mimetypes[".lma"]="audio/x-nspaudio";
$mimetypes[".log"]="text/plain";
$mimetypes[".lsp"]="application/x-lisp";
$mimetypes[".lsp"]="text/x-script.lisp";
$mimetypes[".lst"]="text/plain";
$mimetypes[".lsx"]="text/x-la-asf";
$mimetypes[".ltx"]="application/x-latex";
$mimetypes[".lzh"]="application/octet-stream";
$mimetypes[".lzh"]="application/x-lzh";
$mimetypes[".lzx"]="application/lzx";
$mimetypes[".lzx"]="application/octet-stream";
$mimetypes[".lzx"]="application/x-lzx";
$mimetypes[".m"]="text/plain";
$mimetypes[".m"]="text/x-m";
$mimetypes[".m1v"]="video/mpeg";
$mimetypes[".m2a"]="audio/mpeg";
$mimetypes[".m2v"]="video/mpeg";
$mimetypes[".m3u"]="audio/x-mpequrl";
$mimetypes[".man"]="application/x-troff-man";
$mimetypes[".map"]="application/x-navimap";
$mimetypes[".mar"]="text/plain";
$mimetypes[".mbd"]="application/mbedlet";
$mimetypes[".mc$"]="application/x-magic-cap-package-1.0";
$mimetypes[".mcd"]="application/mcad";
$mimetypes[".mcd"]="application/x-mathcad";
$mimetypes[".mcf"]="image/vasa";
$mimetypes[".mcf"]="text/mcf";
$mimetypes[".mcp"]="application/netmc";
$mimetypes[".me"]="application/x-troff-me";
$mimetypes[".mht"]="message/rfc822";
$mimetypes[".mhtml"]="message/rfc822";
$mimetypes[".mid"]="application/x-midi";
$mimetypes[".mid"]="audio/midi";
$mimetypes[".mid"]="audio/x-mid";
$mimetypes[".mid"]="audio/x-midi";
$mimetypes[".mid"]="music/crescendo";
$mimetypes[".mid"]="x-music/x-midi";
$mimetypes[".midi"]="application/x-midi";
$mimetypes[".midi"]="audio/midi";
$mimetypes[".midi"]="audio/x-mid";
$mimetypes[".midi"]="audio/x-midi";
$mimetypes[".midi"]="music/crescendo";
$mimetypes[".midi"]="x-music/x-midi";
$mimetypes[".mif"]="application/x-frame";
$mimetypes[".mif"]="application/x-mif";
$mimetypes[".mime"]="message/rfc822";
$mimetypes[".mime"]="www/mime";
$mimetypes[".mjf"]="audio/x-vnd.audioexplosion.mjuicemediafile";
$mimetypes[".mjpg"]="video/x-motion-jpeg";
$mimetypes[".mm"]="application/base64";
$mimetypes[".mm"]="application/x-meme";
$mimetypes[".mme"]="application/base64";
$mimetypes[".mod"]="audio/mod";
$mimetypes[".mod"]="audio/x-mod";
$mimetypes[".moov"]="video/quicktime";
$mimetypes[".mov"]="video/quicktime";
$mimetypes[".movie"]="video/x-sgi-movie";
$mimetypes[".mp2"]="audio/mpeg";
$mimetypes[".mp2"]="audio/x-mpeg";
$mimetypes[".mp2"]="video/mpeg";
$mimetypes[".mp2"]="video/x-mpeg";
$mimetypes[".mp2"]="video/x-mpeq2a";
$mimetypes[".mp3"]="audio/mpeg3";
$mimetypes[".mp3"]="audio/x-mpeg-3";
$mimetypes[".mp3"]="video/mpeg";
$mimetypes[".mp3"]="video/x-mpeg";
$mimetypes[".mpa"]="audio/mpeg";
$mimetypes[".mpa"]="video/mpeg";
$mimetypes[".mpc"]="application/x-project";
$mimetypes[".mpe"]="video/mpeg";
$mimetypes[".mpeg"]="video/mpeg";
$mimetypes[".mpg"]="audio/mpeg";
$mimetypes[".mpg"]="video/mpeg";
$mimetypes[".mpga"]="audio/mpeg";
$mimetypes[".mpp"]="application/vnd.ms-project";
$mimetypes[".mpt"]="application/x-project";
$mimetypes[".mpv"]="application/x-project";
$mimetypes[".mpx"]="application/x-project";
$mimetypes[".mrc"]="application/marc";
$mimetypes[".ms"]="application/x-troff-ms";
$mimetypes[".mv"]="video/x-sgi-movie";
$mimetypes[".my"]="audio/make";
$mimetypes[".mzz"]="application/x-vnd.audioexplosion.mzz";
$mimetypes[".nap"]="image/naplps";
$mimetypes[".naplps"]="image/naplps";
$mimetypes[".nc"]="application/x-netcdf";
$mimetypes[".ncm"]="application/vnd.nokia.configuration-message";
$mimetypes[".nif"]="image/x-niff";
$mimetypes[".niff"]="image/x-niff";
$mimetypes[".nix"]="application/x-mix-transfer";
$mimetypes[".nsc"]="application/x-conference";
$mimetypes[".nvd"]="application/x-navidoc";
$mimetypes[".o"]="application/octet-stream";
$mimetypes[".oda"]="application/oda";
$mimetypes[".omc"]="application/x-omc";
$mimetypes[".omcd"]="application/x-omcdatamaker";
$mimetypes[".omcr"]="application/x-omcregerator";
$mimetypes[".p"]="text/x-pascal";
$mimetypes[".p10"]="application/pkcs10";
$mimetypes[".p10"]="application/x-pkcs10";
$mimetypes[".p12"]="application/pkcs-12";
$mimetypes[".p12"]="application/x-pkcs12";
$mimetypes[".p7a"]="application/x-pkcs7-signature";
$mimetypes[".p7c"]="application/pkcs7-mime";
$mimetypes[".p7c"]="application/x-pkcs7-mime";
$mimetypes[".p7m"]="application/pkcs7-mime";
$mimetypes[".p7m"]="application/x-pkcs7-mime";
$mimetypes[".p7r"]="application/x-pkcs7-certreqresp";
$mimetypes[".p7s"]="application/pkcs7-signature";
$mimetypes[".part"]="application/pro_eng";
$mimetypes[".pas"]="text/pascal";
$mimetypes[".pbm"]="image/x-portable-bitmap";
$mimetypes[".pcl"]="application/vnd.hp-pcl";
$mimetypes[".pcl"]="application/x-pcl";
$mimetypes[".pct"]="image/x-pict";
$mimetypes[".pcx"]="image/x-pcx";
$mimetypes[".pdb"]="chemical/x-pdb";
$mimetypes[".pdf"]="application/pdf";
$mimetypes[".pfunk"]="audio/make";
$mimetypes[".pfunk"]="audio/make.my.funk";
$mimetypes[".pgm"]="image/x-portable-graymap";
$mimetypes[".pgm"]="image/x-portable-greymap";
$mimetypes[".pic"]="image/pict";
$mimetypes[".pict"]="image/pict";
$mimetypes[".pkg"]="application/x-newton-compatible-pkg";
$mimetypes[".pko"]="application/vnd.ms-pki.pko";
$mimetypes[".pl"]="text/plain";
$mimetypes[".pl"]="text/x-script.perl";
$mimetypes[".plx"]="application/x-pixclscript";
$mimetypes[".pm"]="image/x-xpixmap";
$mimetypes[".pm"]="text/x-script.perl-module";
$mimetypes[".pm4"]="application/x-pagemaker";
$mimetypes[".pm5"]="application/x-pagemaker";
$mimetypes[".png"]="image/png";
$mimetypes[".pnm"]="application/x-portable-anymap";
$mimetypes[".pnm"]="image/x-portable-anymap";
$mimetypes[".pot"]="application/mspowerpoint";
$mimetypes[".pot"]="application/vnd.ms-powerpoint";
$mimetypes[".pov"]="model/x-pov";
$mimetypes[".ppa"]="application/vnd.ms-powerpoint";
$mimetypes[".ppm"]="image/x-portable-pixmap";
$mimetypes[".pps"]="application/mspowerpoint";
$mimetypes[".pps"]="application/vnd.ms-powerpoint";
$mimetypes[".ppt"]="application/mspowerpoint";
$mimetypes[".ppt"]="application/powerpoint";
$mimetypes[".ppt"]="application/vnd.ms-powerpoint";
$mimetypes[".ppt"]="application/x-mspowerpoint";
$mimetypes[".ppz"]="application/mspowerpoint";
$mimetypes[".pre"]="application/x-freelance";
$mimetypes[".prt"]="application/pro_eng";
$mimetypes[".ps"]="application/postscript";
$mimetypes[".psd"]="application/octet-stream";
$mimetypes[".pvu"]="paleovu/x-pv";
$mimetypes[".pwz"]="application/vnd.ms-powerpoint";
$mimetypes[".py"]="text/x-script.phyton";
$mimetypes[".pyc"]="applicaiton/x-bytecode.python";
$mimetypes[".qcp"]="audio/vnd.qcelp";
$mimetypes[".qd3"]="x-world/x-3dmf";
$mimetypes[".qd3d"]="x-world/x-3dmf";
$mimetypes[".qif"]="image/x-quicktime";
$mimetypes[".qt"]="video/quicktime";
$mimetypes[".qtc"]="video/x-qtc";
$mimetypes[".qti"]="image/x-quicktime";
$mimetypes[".qtif"]="image/x-quicktime";
$mimetypes[".ra"]="audio/x-pn-realaudio";
$mimetypes[".ra"]="audio/x-pn-realaudio-plugin";
$mimetypes[".ra"]="audio/x-realaudio";
$mimetypes[".ram"]="audio/x-pn-realaudio";
$mimetypes[".ras"]="application/x-cmu-raster";
$mimetypes[".ras"]="image/cmu-raster";
$mimetypes[".ras"]="image/x-cmu-raster";
$mimetypes[".rast"]="image/cmu-raster";
$mimetypes[".rexx"]="text/x-script.rexx";
$mimetypes[".rf"]="image/vnd.rn-realflash";
$mimetypes[".rgb"]="image/x-rgb";
$mimetypes[".rm"]="application/vnd.rn-realmedia";
$mimetypes[".rm"]="audio/x-pn-realaudio";
$mimetypes[".rmi"]="audio/mid";
$mimetypes[".rmm"]="audio/x-pn-realaudio";
$mimetypes[".rmp"]="audio/x-pn-realaudio";
$mimetypes[".rmp"]="audio/x-pn-realaudio-plugin";
$mimetypes[".rng"]="application/ringing-tones";
$mimetypes[".rng"]="application/vnd.nokia.ringing-tone";
$mimetypes[".rnx"]="application/vnd.rn-realplayer";
$mimetypes[".roff"]="application/x-troff";
$mimetypes[".rp"]="image/vnd.rn-realpix";
$mimetypes[".rpm"]="audio/x-pn-realaudio-plugin";
$mimetypes[".rt"]="text/richtext";
$mimetypes[".rt"]="text/vnd.rn-realtext";
$mimetypes[".rtf"]="application/rtf";
$mimetypes[".rtf"]="application/x-rtf";
$mimetypes[".rtf"]="text/richtext";
$mimetypes[".rtx"]="application/rtf";
$mimetypes[".rtx"]="text/richtext";
$mimetypes[".rv"]="video/vnd.rn-realvideo";
$mimetypes[".s"]="text/x-asm";
$mimetypes[".s3m"]="audio/s3m";
$mimetypes[".saveme"]="application/octet-stream";
$mimetypes[".sbk"]="application/x-tbook";
$mimetypes[".scm"]="application/x-lotusscreencam";
$mimetypes[".scm"]="text/x-script.guile";
$mimetypes[".scm"]="text/x-script.scheme";
$mimetypes[".scm"]="video/x-scm";
$mimetypes[".sdml"]="text/plain";
$mimetypes[".sdp"]="application/sdp";
$mimetypes[".sdp"]="application/x-sdp";
$mimetypes[".sdr"]="application/sounder";
$mimetypes[".sea"]="application/sea";
$mimetypes[".sea"]="application/x-sea";
$mimetypes[".set"]="application/set";
$mimetypes[".sgm"]="text/sgml";
$mimetypes[".sgm"]="text/x-sgml";
$mimetypes[".sgml"]="text/sgml";
$mimetypes[".sgml"]="text/x-sgml";
$mimetypes[".sh"]="application/x-bsh";
$mimetypes[".sh"]="application/x-sh";
$mimetypes[".sh"]="application/x-shar";
$mimetypes[".sh"]="text/x-script.sh";
$mimetypes[".shar"]="application/x-bsh";
$mimetypes[".shar"]="application/x-shar";
$mimetypes[".shtml"]="text/html";
$mimetypes[".shtml"]="text/x-server-parsed-html";
$mimetypes[".sid"]="audio/x-psid";
$mimetypes[".sit"]="application/x-sit";
$mimetypes[".sit"]="application/x-stuffit";
$mimetypes[".skd"]="application/x-koan";
$mimetypes[".skm"]="application/x-koan";
$mimetypes[".skp"]="application/x-koan";
$mimetypes[".skt"]="application/x-koan";
$mimetypes[".sl"]="application/x-seelogo";
$mimetypes[".smi"]="application/smil";
$mimetypes[".smil"]="application/smil";
$mimetypes[".snd"]="audio/basic";
$mimetypes[".snd"]="audio/x-adpcm";
$mimetypes[".sol"]="application/solids";
$mimetypes[".spc"]="application/x-pkcs7-certificates";
$mimetypes[".spc"]="text/x-speech";
$mimetypes[".spl"]="application/futuresplash";
$mimetypes[".spr"]="application/x-sprite";
$mimetypes[".sprite"]="application/x-sprite";
$mimetypes[".src"]="application/x-wais-source";
$mimetypes[".ssi"]="text/x-server-parsed-html";
$mimetypes[".ssm"]="application/streamingmedia";
$mimetypes[".sst"]="application/vnd.ms-pki.certstore";
$mimetypes[".step"]="application/step";
$mimetypes[".stl"]="application/sla";
$mimetypes[".stl"]="application/vnd.ms-pki.stl";
$mimetypes[".stl"]="application/x-navistyle";
$mimetypes[".stp"]="application/step";
$mimetypes[".sv4cpio"]="application/x-sv4cpio";
$mimetypes[".sv4crc"]="application/x-sv4crc";
$mimetypes[".svf"]="image/vnd.dwg";
$mimetypes[".svf"]="image/x-dwg";
$mimetypes[".svr"]="application/x-world";
$mimetypes[".svr"]="x-world/x-svr";
$mimetypes[".swf"]="application/x-shockwave-flash";
$mimetypes[".t"]="application/x-troff";
$mimetypes[".talk"]="text/x-speech";
$mimetypes[".tar"]="application/x-tar";
$mimetypes[".tbk"]="application/toolbook";
$mimetypes[".tbk"]="application/x-tbook";
$mimetypes[".tcl"]="application/x-tcl";
$mimetypes[".tcl"]="text/x-script.tcl";
$mimetypes[".tcsh"]="text/x-script.tcsh";
$mimetypes[".tex"]="application/x-tex";
$mimetypes[".texi"]="application/x-texinfo";
$mimetypes[".texinfo"]="application/x-texinfo";
$mimetypes[".text"]="application/plain";
$mimetypes[".text"]="text/plain";
$mimetypes[".tgz"]="application/gnutar";
$mimetypes[".tgz"]="application/x-compressed";
$mimetypes[".tif"]="image/tiff";
$mimetypes[".tif"]="image/x-tiff";
$mimetypes[".tiff"]="image/tiff";
$mimetypes[".tiff"]="image/x-tiff";
$mimetypes[".tr"]="application/x-troff";
$mimetypes[".tsi"]="audio/tsp-audio";
$mimetypes[".tsp"]="application/dsptype";
$mimetypes[".tsp"]="audio/tsplayer";
$mimetypes[".tsv"]="text/tab-separated-values";
$mimetypes[".turbot"]="image/florian";
$mimetypes[".txt"]="text/plain";
$mimetypes[".uil"]="text/x-uil";
$mimetypes[".uni"]="text/uri-list";
$mimetypes[".unis"]="text/uri-list";
$mimetypes[".unv"]="application/i-deas";
$mimetypes[".uri"]="text/uri-list";
$mimetypes[".uris"]="text/uri-list";
$mimetypes[".ustar"]="application/x-ustar";
$mimetypes[".ustar"]="multipart/x-ustar";
$mimetypes[".uu"]="application/octet-stream";
$mimetypes[".uu"]="text/x-uuencode";
$mimetypes[".uue"]="text/x-uuencode";
$mimetypes[".vcd"]="application/x-cdlink";
$mimetypes[".vcs"]="text/x-vcalendar";
$mimetypes[".vda"]="application/vda";
$mimetypes[".vdo"]="video/vdo";
$mimetypes[".vew"]="application/groupwise";
$mimetypes[".viv"]="video/vivo";
$mimetypes[".viv"]="video/vnd.vivo";
$mimetypes[".vivo"]="video/vivo";
$mimetypes[".vivo"]="video/vnd.vivo";
$mimetypes[".vmd"]="application/vocaltec-media-desc";
$mimetypes[".vmf"]="application/vocaltec-media-file";
$mimetypes[".voc"]="audio/voc";
$mimetypes[".voc"]="audio/x-voc";
$mimetypes[".vos"]="video/vosaic";
$mimetypes[".vox"]="audio/voxware";
$mimetypes[".vqe"]="audio/x-twinvq-plugin";
$mimetypes[".vqf"]="audio/x-twinvq";
$mimetypes[".vql"]="audio/x-twinvq-plugin";
$mimetypes[".vrml"]="application/x-vrml";
$mimetypes[".vrml"]="model/vrml";
$mimetypes[".vrml"]="x-world/x-vrml";
$mimetypes[".vrt"]="x-world/x-vrt";
$mimetypes[".vsd"]="application/x-visio";
$mimetypes[".vst"]="application/x-visio";
$mimetypes[".vsw"]="application/x-visio";
$mimetypes[".w60"]="application/wordperfect6.0";
$mimetypes[".w61"]="application/wordperfect6.1";
$mimetypes[".w6w"]="application/msword";
$mimetypes[".wav"]="audio/wav";
$mimetypes[".wav"]="audio/x-wav";
$mimetypes[".wb1"]="application/x-qpro";
$mimetypes[".wbmp"]="image/vnd.wap.wbmp";
$mimetypes[".web"]="application/vnd.xara";
$mimetypes[".wiz"]="application/msword";
$mimetypes[".wk1"]="application/x-123";
$mimetypes[".wmf"]="windows/metafile";
$mimetypes[".wml"]="text/vnd.wap.wml";
$mimetypes[".wmlc"]="application/vnd.wap.wmlc";
$mimetypes[".wmls"]="text/vnd.wap.wmlscript";
$mimetypes[".wmlsc"]="application/vnd.wap.wmlscriptc";
$mimetypes[".word"]="application/msword";
$mimetypes[".wp"]="application/wordperfect";
$mimetypes[".wp5"]="application/wordperfect";
$mimetypes[".wp5"]="application/wordperfect6.0";
$mimetypes[".wp6"]="application/wordperfect";
$mimetypes[".wpd"]="application/wordperfect";
$mimetypes[".wpd"]="application/x-wpwin";
$mimetypes[".wq1"]="application/x-lotus";
$mimetypes[".wri"]="application/mswrite";
$mimetypes[".wri"]="application/x-wri";
$mimetypes[".wrl"]="application/x-world";
$mimetypes[".wrl"]="model/vrml";
$mimetypes[".wrl"]="x-world/x-vrml";
$mimetypes[".wrz"]="model/vrml";
$mimetypes[".wrz"]="x-world/x-vrml";
$mimetypes[".wsc"]="text/scriplet";
$mimetypes[".wsrc"]="application/x-wais-source";
$mimetypes[".wtk"]="application/x-wintalk";
$mimetypes[".xbm"]="image/x-xbitmap";
$mimetypes[".xbm"]="image/x-xbm";
$mimetypes[".xbm"]="image/xbm";
$mimetypes[".xdr"]="video/x-amt-demorun";
$mimetypes[".xgz"]="xgl/drawing";
$mimetypes[".xif"]="image/vnd.xiff";
$mimetypes[".xl"]="application/excel";
$mimetypes[".xla"]="application/excel";
$mimetypes[".xla"]="application/x-excel";
$mimetypes[".xla"]="application/x-msexcel";
$mimetypes[".xlb"]="application/excel";
$mimetypes[".xlb"]="application/vnd.ms-excel";
$mimetypes[".xlb"]="application/x-excel";
$mimetypes[".xlc"]="application/excel";
$mimetypes[".xlc"]="application/vnd.ms-excel";
$mimetypes[".xlc"]="application/x-excel";
$mimetypes[".xld"]="application/excel";
$mimetypes[".xld"]="application/x-excel";
$mimetypes[".xlk"]="application/excel";
$mimetypes[".xlk"]="application/x-excel";
$mimetypes[".xll"]="application/excel";
$mimetypes[".xll"]="application/vnd.ms-excel";
$mimetypes[".xll"]="application/x-excel";
$mimetypes[".xlm"]="application/excel";
$mimetypes[".xlm"]="application/vnd.ms-excel";
$mimetypes[".xlm"]="application/x-excel";
$mimetypes[".xls"]="application/excel";
$mimetypes[".xls"]="application/vnd.ms-excel";
$mimetypes[".xls"]="application/x-excel";
$mimetypes[".xls"]="application/x-msexcel";
$mimetypes[".xlt"]="application/excel";
$mimetypes[".xlt"]="application/x-excel";
$mimetypes[".xlv"]="application/excel";
$mimetypes[".xlv"]="application/x-excel";
$mimetypes[".xlw"]="application/excel";
$mimetypes[".xlw"]="application/vnd.ms-excel";
$mimetypes[".xlw"]="application/x-excel";
$mimetypes[".xlw"]="application/x-msexcel";
$mimetypes[".xm"]="audio/xm";
$mimetypes[".xml"]="application/xml";
$mimetypes[".xml"]="text/xml";
$mimetypes[".xmz"]="xgl/movie";
$mimetypes[".xpix"]="application/x-vnd.ls-xpix";
$mimetypes[".xpm"]="image/x-xpixmap";
$mimetypes[".xpm"]="image/xpm";
$mimetypes[".x-png"]="image/png";
$mimetypes[".xsr"]="video/x-amt-showrun";
$mimetypes[".xwd"]="image/x-xwd";
$mimetypes[".xwd"]="image/x-xwindowdump";
$mimetypes[".xyz"]="chemical/x-pdb";
$mimetypes[".z"]="application/x-compress";
$mimetypes[".z"]="application/x-compressed";
$mimetypes[".zip"]="application/x-compressed";
$mimetypes[".zip"]="application/x-zip-compressed";
$mimetypes[".zip"]="application/zip";
$mimetypes[".zip"]="multipart/x-zip";
$mimetypes[".zoo"]="application/octet-stream";
$mimetypes[".zsh"]="text/x-script.zsh";

$documentid = mysql_escape_string($_REQUEST["documentid"]);
if ($documentid!=""){

	$con = db_connect();
	
	// find out where the file is
	$sql = "SELECT doc.cOriginalFilename,rep.cPath FROM ".$db_tableprefix."Document doc"
		." INNER JOIN ".$db_tableprefix."DocumentType dt ON doc.nDocumentTypeId=dt.nDocumentTypeId"
		." INNER JOIN ".$db_tableprefix."Repository rep ON dt.nRepositoryId=rep.nRepositoryId"
		." WHERE doc.nDocumentId=".$documentid;

	$result = mysql_query($sql,$con);
	
	if ($result!=false){
		if (mysql_num_rows($result)>0){
			$row = mysql_fetch_array($result);

			$filename = stripslashes($row["cPath"])."/".$documentid;
			if (file_exists($filename)){

				// stream the file to the user
				ob_start();
				
				if ($mimetypes[substr(stripslashes($row["cOriginalFilename"]),count(stripslashes($row["cOriginalFilename"]))-4,4)]!=""){
					header("Content-Type: ".$mimetypes[substr(stripslashes($row["cOriginalFilename"]),count(stripslashes($row["cOriginalFilename"]))-4,4)]);
				} else {
					header("Content-Type: application/force-download");
				}
				
				header("Content-Type: application/pdf"); 
				header("Content-Description: File Transfer");
				header("Content-Disposition: inline; filename=".stripslashes($row["cOriginalFilename"]));
				header("Content-Length: ".filesize($filename));
				header("Content-Transfer-Encoding: binary");
				header("Pragma: public");
				header("Expires: 0");
				
				/*
				$chunksize = 1*(1024*1024); // how many bytes per chunk
				$buffer = '';
				$handle = fopen($filename, 'rb');
				if ($handle != false) {
					while (!feof($handle)) {
						$buffer = fread($handle, $chunksize);
						print $buffer;
					}
  					$result = fclose($handle);
  				}
				*/

				$value = readfile($filename);
				
				ob_end_flush();
				
			} else {
				// file not found in repository
				$result = "-5";
				$html_result = "<br><br><table border='0' cellspacing='1' cellpadding='3' align='center' width='400' bgcolor='#aaaabb'>"
					."<tr><td bgcolor='#aaaabb' style='font-family:Verdana,Arial;font-size:11px;font-weight:normal;'><b>Fetch Document Error</b></td></tr>\n"
					."<tr><td bgcolor='#ffffff'>"
					."<table width='100%'><tr><td valign='top' width='48'><img src='images/icon_problem.png'></td><td valign='top'>"
					."<div style='font-family:Verdana,Arial;font-size:18px;font-weight:bold;'>File Download Problem</div>"
					."<div style='font-family:Verdana,Arial;font-size:12px;font-weight:normal;padding:5px;'>The content management system has experienced difficulties as described below - for assistance, contact your IT support staff.</div>"
					."<div style='font-family:Verdana,Arial;font-size:12px;font-weight:normal;padding:5px;'>The file you are trying to download (".stripslashes($row["cOriginalFilename"]).") cannot be found in the repository.</div>"
					."<div style='font-family:Verdana,Arial;font-size:12px;font-weight:normal;padding:5px;'>File : fetch_document.php<br>Error Code : -5</div>"
					."</td></tr></table>\n"					
					."</td></tr>"
					."</table>\n";
			}
		} else {
			//
			$result = "-3";
			
			$html_result = "<br><br><table border='0' cellspacing='1' cellpadding='3' align='center' width='400' bgcolor='#aaaabb'>"
				."<tr><td bgcolor='#aaaabb' style='font-family:Verdana,Arial;font-size:11px;font-weight:normal;'><b>Fetch Document Error</b></td></tr>\n"
				."<tr><td bgcolor='#ffffff'>"
				."<table width='100%'><tr><td valign='top' width='48'><img src='images/icon_problem.png'></td><td valign='top'>"
				."<div style='font-family:Verdana,Arial;font-size:18px;font-weight:bold;'>Document Not Found</div>"
				."<div style='font-family:Verdana,Arial;font-size:12px;font-weight:normal;padding:5px;'>The content management system has experienced difficulties as described below - for assistance, contact your IT support staff.</div>"
				."<div style='font-family:Verdana,Arial;font-size:12px;font-weight:normal;padding:5px;'>The document you are trying to retrieve could not be found in the repository database. This could be either because the repository no longer exists, or the document record no longer exists.</div>"
				."<div style='font-family:Verdana,Arial;font-size:12px;font-weight:normal;padding:5px;'>File : fetch_document.php<br>Error Code : -5</div>"
				."</td></tr></table>\n"					
				."</td></tr>"
				."</table>\n";
		}
	} else {
		$result = "-2";
	}

} else {
	$result = "-1";
}

?>
Return current item: PluggedOut CMS