From 3bdf0b110f4c5880307e871fbcdb737ee6f915da Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 13 Jan 2015 21:51:36 +0100 Subject: added a way to specify the download and count directories The constructor of the class takes them as optional arguments Signed-off-by: Olivier Gayot --- PHP_DW.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'PHP_DW.php') diff --git a/PHP_DW.php b/PHP_DW.php index 8c20cba..d119082 100644 --- a/PHP_DW.php +++ b/PHP_DW.php @@ -1,19 +1,30 @@ dw_dir = $dw_dir; + } + + if ($cnt_dir) { + $this->cnt_dir = $cnt_dir; + } + } private function __get_full_path($path) { if (basename($path) !== $path) { return null; } - return $this->base_dw . '/' . $path; + return $this->dw_dir . '/' . $path; } private function __incr_count($filename) { - $fh = @fopen($this->base_count . '/' . $filename . '.cnt', "a+"); + $fh = @fopen($this->cnt_dir . '/' . $filename . '.cnt', "a+"); if (is_resource($fh) and flock($fh, LOCK_EX)) { rewind($fh); @@ -54,7 +65,7 @@ class PHP_DW { if (!$this->__get_full_path($filename)) return 0; - $fh = @fopen($this->base_count . '/' . $filename . '.cnt', "r"); + $fh = @fopen($this->cnt_dir . '/' . $filename . '.cnt', "r"); if (!is_resource($fh)) return 0; @@ -65,5 +76,13 @@ class PHP_DW { return $count; } + + public function get_count_dir() { + return $this->cnt_dir; + } + + public function get_download_dir() { + return $this->dw_dir; + } } ?> -- cgit v1.2.3