[Fusionforge-commits] FusionForge branch master updated. 8b6d6f17dab55a47e9b6d664b4ae2f7ce4acfdd6

Franck VILLAUME nerville at fusionforge.org
Mon Apr 15 23:42:54 CEST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  8b6d6f17dab55a47e9b6d664b4ae2f7ce4acfdd6 (commit)
      from  9b07236a38f93323231a920475010a775af019b3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8b6d6f17dab55a47e9b6d664b4ae2f7ce4acfdd6
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Mon Apr 15 23:41:23 2013 +0200

    fix #428: latest-zip does not increment download stats

diff --git a/src/www/frs/download.php b/src/www/frs/download.php
index 66e6210..b76ffe0 100644
--- a/src/www/frs/download.php
+++ b/src/www/frs/download.php
@@ -5,6 +5,7 @@
  * Copyright 1999-2001 (c) VA Linux Systems
  * Copyright 2002-2004 (c) GForge Team
  * Copyright 2010 (c) FusionForge Team
+ * Copyright 2013, Franck Villaume - TrivialDev
  * http://fusionforge.org/
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -41,7 +42,7 @@ require_once $gfcommon.'frs/FRSFile.class.php';
  *   package_id)
  */
 
-function send_file ($filename,$filepath,$file_id=NULL) {
+function send_file($filename, $filepath, $file_id = NULL, $mode = NULL) {
 	if (!file_exists($filepath)) {
 		session_redirect404();
 	}
@@ -65,7 +66,17 @@ function send_file ($filename,$filepath,$file_id=NULL) {
 	}
 
 	$ip = getStringFromServer('REMOTE_ADDR');
-	$res = db_query_params("INSERT INTO frs_dlstats_file (ip_address,file_id,month,day,user_id) VALUES ($1, $2, $3, $4, $5)", array($ip,$file_id,date('Ym'),date('d'),$us));
+	if ($mode != 'latestzip') {
+		$res = db_query_params("INSERT INTO frs_dlstats_file (ip_address,file_id,month,day,user_id) VALUES ($1, $2, $3, $4, $5)", array($ip,$file_id,date('Ym'),date('d'),$us));
+	} else {
+		// here $file_id is a package_id
+		$Package = frspackage_get_object($file_id);
+		$release = $Package->getNewestRelease();
+		$files = $release->getFiles();
+		foreach ($files as $fileObject) {
+			$res = db_query_params("INSERT INTO frs_dlstats_file (ip_address,file_id,month,day,user_id) VALUES ($1, $2, $3, $4, $5)", array($ip, $fileObject->getID(), date('Ym'), date('d'), $us));
+		}
+	}
 }
 
 $normalized_urlprefix = normalized_urlprefix();
@@ -120,7 +131,7 @@ case 'latestzip':
 
 	$filename = $Package->getNewestReleaseZipName();
 	$filepath = $Package->getNewestReleaseZipPath();
-	send_file ($filename, $filepath);
+	send_file ($filename, $filepath, $package_id, $mode);
 
 	break;
 

-----------------------------------------------------------------------

Summary of changes:
 src/www/frs/download.php |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list