1 | <?php |
||
14 | trait Upload { |
||
15 | |||
16 | protected $file; |
||
17 | /** |
||
18 | *@var string contains an array of valid extensions which are allowed to be uploaded. |
||
19 | */ |
||
20 | protected $ValidExtensions; |
||
21 | /** |
||
22 | *@var string contains a message which can be used for debugging. |
||
23 | */ |
||
24 | protected $Message; |
||
25 | /** |
||
26 | *@var integer contains maximum size of fiels to be uploaded in bytes. |
||
27 | */ |
||
28 | protected $MaximumFileSize; |
||
29 | /** |
||
30 | *@var bool contains whether or not the files being uploaded are images. |
||
31 | */ |
||
32 | protected $IsImage; |
||
33 | /** |
||
34 | *@var string contains the email address of the recipient of upload logs. |
||
35 | */ |
||
36 | protected $Email; |
||
37 | /** |
||
38 | *@var integer contains maximum width of images to be uploaded. |
||
39 | */ |
||
40 | protected $MaximumWidth; |
||
41 | /** |
||
42 | *@var integer contains maximum height of images to be uploaded. |
||
43 | */ |
||
44 | protected $MaximumHeight; |
||
45 | |||
46 | // public function upload() |
||
|
|||
47 | // { |
||
48 | |||
49 | // } |
||
50 | |||
51 | public function file($file) |
||
57 | |||
58 | // public function fileSize() |
||
59 | // { |
||
60 | // return $this->output['size']; |
||
61 | // } |
||
62 | |||
63 | // public function fileTmp() |
||
64 | // { |
||
65 | // return $this->output['tmp_name']; |
||
66 | // } |
||
67 | |||
68 | // public function fileName() |
||
69 | // { |
||
70 | // return $this->output; |
||
71 | // } |
||
72 | |||
73 | // public function fileMove($destination, $fileName = NULL) |
||
74 | // { |
||
75 | // $file_name = ($fileName == null) ? $this->fileName() : $fileName; |
||
76 | // if (move_uploaded_file($this->fileTmp(), $destination.'/'.$file_name)) { |
||
77 | // return 333; |
||
78 | // } else { |
||
79 | // return 000; |
||
80 | // } |
||
81 | // } |
||
82 | |||
83 | /** |
||
84 | *@method bool ValidateExtension() returns whether the extension of file to be uploaded |
||
85 | * is allowable or not. |
||
86 | *@return true the extension is valid. |
||
87 | *@return false the extension is invalid. |
||
88 | */ |
||
89 | public function ValidateExtension() |
||
115 | |||
116 | /** |
||
117 | *@method bool ValidateSize() returns whether the file size is acceptable. |
||
118 | *@return true the size is smaller than the alloted value. |
||
119 | *@return false the size is larger than the alloted value. |
||
120 | */ |
||
121 | public function ValidateSize() |
||
140 | |||
141 | /** |
||
142 | *@method bool ValidateExistance() determins whether the file already exists. If so, rename $FileName. |
||
143 | *@return true can never be returned as all file names must be unique. |
||
144 | *@return false the file name does not exist. |
||
145 | */ |
||
146 | public function ValidateExistance($uploadDirectory) |
||
161 | |||
162 | /** |
||
163 | *@method bool ValidateDirectory() |
||
164 | *@return true the UploadDirectory exists, writable, and has a traling slash. |
||
165 | *@return false the directory was never set, does not exist, or is not writable. |
||
166 | */ |
||
167 | public function ValidateDirectory($uploadDirectory) |
||
194 | |||
195 | /** |
||
196 | *@method bool ValidateImage() |
||
197 | *@return true the image is smaller than the alloted dimensions. |
||
198 | *@return false the width and/or height is larger then the alloted dimensions. |
||
199 | */ |
||
200 | public function ValidateImage() { |
||
223 | |||
224 | /** |
||
225 | *@method bool UploadFile() uploads the file to the server after passing all the validations. |
||
226 | *@return true the file was uploaded. |
||
227 | *@return false the upload failed. |
||
228 | */ |
||
229 | public function uploadFile($uploadDirectory) |
||
267 | |||
268 | #Accessors and Mutators beyond this point. |
||
269 | #Siginificant documentation is not needed. |
||
270 | public function SetValidExtensions($argv) |
||
274 | |||
275 | public function SetMessage($argv) |
||
279 | |||
280 | public function SetMaximumFileSize($argv) |
||
284 | |||
285 | public function SetEmail($argv) |
||
289 | |||
290 | public function SetIsImage($argv) |
||
294 | |||
295 | public function SetMaximumWidth($argv) |
||
299 | |||
300 | public function SetMaximumHeight($argv) |
||
308 | |||
309 | public function GetUploadDirectory() |
||
313 | |||
314 | public function GetTempName() |
||
318 | |||
319 | public function GetValidExtensions() |
||
323 | |||
324 | public function GetMessage() |
||
332 | |||
333 | public function GetMaximumFileSize() |
||
337 | |||
338 | public function GetIsImage() |
||
342 | |||
343 | public function GetMaximumWidth() |
||
347 | |||
348 | public function GetMaximumHeight() |
||
352 | } |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.