From 1203aa5331d947d1b73e41d76197ff4815fe3759 Mon Sep 17 00:00:00 2001 From: Radex Date: Tue, 24 Feb 2009 18:15:56 +0100 Subject: [PATCH] =?utf8?q?download:=20pobieranie=20nie=20bezpo=C5=9Brednio?= =?utf8?q?=20z=20serwera=20(aby=20mo=C5=BCna=20by=C5=82o=20liczy=C4=87=20i?= =?utf8?q?lo=C5=9B=C4=87=20download=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- wtrmln/modules/controllers/download.php | 21 +++++++++++++++++++++ wtrmln/modules/models/model_download.php | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/wtrmln/modules/controllers/download.php b/wtrmln/modules/controllers/download.php index ab43a49..74b72ee 100644 --- a/wtrmln/modules/controllers/download.php +++ b/wtrmln/modules/controllers/download.php @@ -53,5 +53,26 @@ class Download extends Controller echo $this->load->view('download_files', array('files' => $files)); } + + /* + * ściąganie + */ + + function get() + { + $id = $this->url->segment(1); + + $data = model('download')->FileData($id); + + if(!$data->exists()) + { + echo $this->load->view('download_nosuchfile'); + return; + } + + model('download')->IncDownloads($id); + + redirect($data->to_obj()->url); + } } ?> \ No newline at end of file diff --git a/wtrmln/modules/models/model_download.php b/wtrmln/modules/models/model_download.php index 79455fd..2e8b697 100644 --- a/wtrmln/modules/models/model_download.php +++ b/wtrmln/modules/models/model_download.php @@ -182,5 +182,18 @@ class Model_Download extends Model return $gid; } + + /* + * public void IncDownloads(uint $id) + * + * inkrementuje licznik ściągnięć pliku o ID=$id + */ + + public function IncDownloads($id) + { + $id = intval($id); + + $this->db->query("UPDATE `__download_files` SET `downloads` = `downloads` + 1 WHERE `id` = '%1'", $id); + } } ?> \ No newline at end of file -- 2.11.4.GIT