summaryrefslogtreecommitdiff
path: root/PHP_DW.php
diff options
context:
space:
mode:
Diffstat (limited to 'PHP_DW.php')
-rw-r--r--PHP_DW.php29
1 files changed, 24 insertions, 5 deletions
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 @@
<?php
class PHP_DW {
- private $base_dw = 'downloads';
- private $base_count = '.count';
+ private $dw_dir = 'downloads';
+ private $cnt_dir = '.count';
+
+ function __construct($dw_dir = false, $cnt_dir = false) {
+
+ if ($dw_dir) {
+ $this->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;
+ }
}
?>