MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
EasyDownload.class
Ir para a documentação deste ficheiro.
1<?php
9{
14 var $Path;
17
22 function EasyDownload()
23 {
24 $this->ContentType = "application/save";
25 $this->ContentLength = "";
26 $this->ContentDisposition = "";
27 $this->ContentTransferEncoding = "";
28 $this->Path = "";
29 $this->FileName = "";
30 $this->FileNameDown = "";
31 }
32
38 function setContentType($strValue)
39 {
40 $this->ContentType = $strValue;
41 }
42
49 {
50 $this->ContentLength = filesize($this->Path . "/" . $this->FileName);
51 }
52
57 function setContentDisposition($strValue)
58 {
59 $this->ContentDisposition = $strValue;
60 }
61
66 function setContentTransferEncoding($strValue)
67 {
68 $this->ContentTransferEncoding = $strValue;
69 }
70
75 function setPath($strValue)
76 {
80 if (strpos($strValue, "..") === false)
81 {
82 $this->Path = $strValue;
83 }
84 else
85 {
86 die ("Trying to access an URL with '..'");
87 }
88 }
89
94 function setFileName($strValue)
95 {
99 if (strpos($strValue, "..") === false)
100 {
101 $this->FileName = $strValue;
102 }
103 else
104 {
105 die ("Trying to access an URL with '..'");
106 }
107 }
108
114 function setFileNameDown($strValue)
115 {
116 $this->FileNameDown = $strValue;
117 }
118
123 function send()
124 {
125 $this->_setContentLength();
126 header ("Content-Type: " . $this->ContentType);
127 header ("Content-Length: " . $this->ContentLength);
128
129 if ($this->FileNameDown == "")
130 header ("Content-Disposition: attachment; filename=" . $this->FileName);
131 else
132 header ("Content-Disposition: attachment; filename=" . $this->FileNameDown);
133
134 header ("Content-Transfer-Encoding: binary");
135 $fp = fopen($this->Path . "/" . $this->FileName, "r");
136 fpassthru ($fp);
137 fclose ($fp);
138 exit();
139 }
140}
141?>
setPath($strValue)
setFileNameDown($strValue)
setFileName($strValue)
setContentDisposition($strValue)
setContentTransferEncoding($strValue)
setContentType($strValue)