Access denied for user 'down_skrasek_com'@'localhost' (using password: YES)
File: /app/controllers/files-controller.php Line: 13
1<?php
2
3
4class FilesController extends AppController
5{
6
7
8 protected $file;
9
10
11 public function init()
12 {
13 $this->load('db');
14 $this->view->view(false);
15 }
16
17
18 public function trunkAction($package, $trunk)
19 {
20 $this->file = db::fetch('select * from files where [package] = %s', $package,
21 ' and [trunk] = %s', $trunk, ' order by [revision] DESC limit 1');
22 }
23
24
25 public function packageAction($package)
26 {
27 $this->file = db::fetch('select * from files where [package] = %s', $package,
28 ' order by [trunk] DESC , [revision] DESC limit 1');
29 }
30
31
32 public function fileAction($filename)
33 {
34 $this->file = db::fetch('select * from files where [filename] = %s', $filename,' limit 1');
35 }
36
37
38 public function afterAction()
39 {
40 if (empty($this->file))
41 $this->error();
42
43 db::query('update [files] set [downloaded] = [downloaded] + 1 where [id] = %i', $this->file->id);
44 $file = dirname(__FILE__) . '/../../../../files/' . $this->file->package . '/' . $this->file->filename;
45
46 if (!file_exists($file))
47 $this->error();
48
49
50 header('Content-Description: File Transfer');
51 header('Content-Type: application/octet-stream');
52 header('Content-Disposition: attachment; filename='.basename($file));
53 header('Content-Transfer-Encoding: binary');
54 header('Expires: 0');
55 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
56 header('Pragma: public');
57 header('Content-Length: ' . filesize($file));
58 /*ob_clean();
59 flush();*/
60 readfile($file);
61 exit;
62 }
63
64
65}
Rendered contents:
| rendering time: | 15.55ms |
|---|---|
| server: | download.skrasek.com:80 |
| generated at: | 04.02.2012, 11.52 |
| háefko 0.8 |