From 4c690b1c41bc37688ab4bb730949737eeef1b7d5 Mon Sep 17 00:00:00 2001
From: Robert Anderson <randerson@lbsd.net>
Date: Tue, 4 Aug 2009 13:10:08 +0000
Subject: [PATCH] Only cap users after showing logs for both traffic and uptime
 now

---
 .../modules/features/mod_feature_capping.pm   | 36 +++++++++----------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/smradius/modules/features/mod_feature_capping.pm b/smradius/modules/features/mod_feature_capping.pm
index 17232780..c4dee12c 100644
--- a/smradius/modules/features/mod_feature_capping.pm
+++ b/smradius/modules/features/mod_feature_capping.pm
@@ -183,15 +183,6 @@ sub post_auth_hook
 				"Min (Cap: Uncapped, Topups: ".$uptimeTopup."Min)");
 	}
 
-	# If uptime limit exceeded, cap user
-	if (!(defined($uptimeLimit->{':='}->{'Value'}) && $uptimeLimit->{':='}->{'Value'} == 0)) {
-		if ($accountingUsage->{'TotalTimeUsage'} >= $alteredUptimeLimit) {
-			$server->log(LOG_DEBUG,"[MOD_FEATURE_CAPPING] Usage of ".$accountingUsage->{'TotalTimeUsage'}.
-					"Min exceeds allowed limit of ".$alteredUptimeLimit."Min. Capped.");
-			return MOD_RES_NACK;
-		}
-	}
-
 	# Get topups
 	my $trafficTopup = 0;
 	if (defined($user->{'ConfigAttributes'}->{$TRAFFIC_TOPUPS_KEY})) {
@@ -249,6 +240,15 @@ sub post_auth_hook
 		}
 	}
 
+	# If uptime limit exceeded, cap user
+	if (!(defined($uptimeLimit->{':='}->{'Value'}) && $uptimeLimit->{':='}->{'Value'} == 0)) {
+		if ($accountingUsage->{'TotalTimeUsage'} >= $alteredUptimeLimit) {
+			$server->log(LOG_DEBUG,"[MOD_FEATURE_CAPPING] Usage of ".$accountingUsage->{'TotalTimeUsage'}.
+					"Min exceeds allowed limit of ".$alteredUptimeLimit."Min. Capped.");
+			return MOD_RES_NACK;
+		}
+	}
+
 	return MOD_RES_ACK;
 }
 
@@ -376,15 +376,6 @@ sub post_acct_hook
 				"Min (Cap: Uncapped, Topups: ".$uptimeTopup."Min)");
 	}
 
-	# If uptime limit exceeded, cap user
-	if (!(defined($uptimeLimit->{':='}->{'Value'}) && $uptimeLimit->{':='}->{'Value'} == 0)) {
-		if ($accountingUsage->{'TotalTimeUsage'} >= $alteredUptimeLimit) {
-			$server->log(LOG_DEBUG,"[MOD_FEATURE_CAPPING] Usage of ".$accountingUsage->{'TotalTimeUsage'}.
-					"Min exceeds allowed limit of ".$alteredUptimeLimit."Min. Capped.");
-			return MOD_RES_NACK;
-		}
-	}
-
 	# Get topups
 	my $trafficTopup = 0;
 	if (defined($user->{'ConfigAttributes'}->{$TRAFFIC_TOPUPS_KEY})) {
@@ -442,6 +433,15 @@ sub post_acct_hook
 		}
 	}
 
+	# If uptime limit exceeded, cap user
+	if (!(defined($uptimeLimit->{':='}->{'Value'}) && $uptimeLimit->{':='}->{'Value'} == 0)) {
+		if ($accountingUsage->{'TotalTimeUsage'} >= $alteredUptimeLimit) {
+			$server->log(LOG_DEBUG,"[MOD_FEATURE_CAPPING] Usage of ".$accountingUsage->{'TotalTimeUsage'}.
+					"Min exceeds allowed limit of ".$alteredUptimeLimit."Min. Capped.");
+			return MOD_RES_NACK;
+		}
+	}
+
 	return MOD_RES_ACK;
 }
 
-- 
GitLab