Skip to content

Commit

Permalink
Add total downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Obihoernchen committed May 9, 2012
1 parent 33f6a67 commit d732b67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
22 changes: 19 additions & 3 deletions resources/DirectoryLister.php
Expand Up @@ -16,7 +16,7 @@
class DirectoryLister {

// Define application version
const VERSION = '2.1.0';
const VERSION = '2.1.1';

// Reserve some variables
protected $_themeName = NULL;
Expand Down Expand Up @@ -236,6 +236,22 @@ public function getSystemMessages() {
}
}

/**
* Get total download count.
*
* @return download number
* @access public
*/
public function getTotalDownloads() {

// Get fresh download count data
$dllog = $this->_read_log();

// Get total download count
$totaldls = array_sum($dllog);
return $totaldls;
}

/**
* Validates and returns the directory path
*
Expand Down Expand Up @@ -373,7 +389,7 @@ private function _readDirectory($directory, $sort = 'natcase') {
// Add all non-hidden files to the array
if ($this->_directory != '.' || $file != 'index.php') {
// Get donwload counts
if (@array_key_exists($relativePath,$dllog)) {
if (@array_key_exists($relativePath,$dllog)) {
$downloads = $dllog[$relativePath];
}
else {
Expand Down Expand Up @@ -404,7 +420,7 @@ private function _readDirectory($directory, $sort = 'natcase') {
}

// Function to read the log file, and return an array as (filename => downloads)
private function _read_log() {
private function _read_log() {

// Declare Array for holding data read from log file
$name = array(); // array for file name
Expand Down
1 change: 1 addition & 0 deletions resources/themes/bootstrap/index.php
Expand Up @@ -69,6 +69,7 @@

<div class="footer">
<p>Powered by, <a href="http://www.directorylister.com">Directory Lister</a></p>
<p>Total Downloads: <?php echo $lister->getTotalDownloads(); ?></p>
</div>

</div>
Expand Down

0 comments on commit d732b67

Please sign in to comment.