/usr/local/miolo2/classes/contrib/EasyDownload.class

Go to the documentation of this file.
00001 <?php
00008 class EasyDownload
00009 {
00010     var $ContentType;
00011     var $ContentLength;
00012     var $ContentDisposition;
00013     var $ContentTransferEncoding;
00014     var $Path;
00015     var $FileName;
00016     var $FileNameDown;
00017 
00022     function EasyDownload()
00023     {
00024         $this->ContentType = "application/save";
00025         $this->ContentLength = "";
00026         $this->ContentDisposition = "";
00027         $this->ContentTransferEncoding = "";
00028         $this->Path = "";
00029         $this->FileName = "";
00030         $this->FileNameDown = "";
00031     }
00032 
00038     function setContentType($strValue)
00039     {
00040         $this->ContentType = $strValue;
00041     }
00042 
00048     function _setContentLength()
00049     {
00050         $this->ContentLength = filesize($this->Path . "/" . $this->FileName);
00051     }
00052 
00057     function setContentDisposition($strValue)
00058     {
00059         $this->ContentDisposition = $strValue;
00060     }
00061 
00066     function setContentTransferEncoding($strValue)
00067     {
00068         $this->ContentTransferEncoding = $strValue;
00069     }
00070 
00075     function setPath($strValue)
00076     {
00080         if (strpos($strValue, "..") === false)
00081         {
00082             $this->Path = $strValue;
00083         }
00084         else
00085         {
00086             die ("Trying to access an URL with '..'");
00087         }
00088     }
00089 
00094     function setFileName($strValue)
00095     {
00099         if (strpos($strValue, "..") === false)
00100         {
00101             $this->FileName = $strValue;
00102         }
00103         else
00104         {
00105             die ("Trying to access an URL with '..'");
00106         }
00107     }
00108 
00114     function setFileNameDown($strValue)
00115     {
00116         $this->FileNameDown = $strValue;
00117     }
00118 
00123     function send()
00124     {
00125         $this->_setContentLength();
00126         header ("Content-Type: " . $this->ContentType);
00127         header ("Content-Length: " . $this->ContentLength);
00128 
00129         if ($this->FileNameDown == "")
00130             header ("Content-Disposition: attachment; filename=" . $this->FileName);
00131         else
00132             header ("Content-Disposition: attachment; filename=" . $this->FileNameDown);
00133 
00134         header ("Content-Transfer-Encoding: binary");
00135         $fp = fopen($this->Path . "/" . $this->FileName, "r");
00136         fpassthru ($fp);
00137         fclose ($fp);
00138         exit();
00139     }
00140 }
00141 ?>
CopyLeft (L) 2001-2006 - [MIOLO Development Team] SOLIS - Cooperativa de Soluções Livres - Lajeado/RS - Brasil