diff -ur abills.orig/Abills/mysql/Billing.pm abills/Abills/mysql/Billing.pm
--- abills.orig/Abills/mysql/Billing.pm	2008-05-03 04:27:35.000000000 +0400
+++ abills/Abills/mysql/Billing.pm	2008-06-01 09:12:55.000000000 +0400
@@ -1171,7 +1171,7 @@
       	  	  }
              else {
              	 #print "# Not allow hour $remaining_time";
-             	 # return -2;
+             	  return -2;
               }
       	   }
        	  #return $remaining_time;
diff -ur abills.orig/libexec/billd abills/libexec/billd
--- abills.orig/libexec/billd	2008-03-26 14:06:09.000000000 +0300
+++ abills/libexec/billd	2008-06-02 19:47:32.000000000 +0400
@@ -136,6 +138,7 @@
 		                   #%LIST_PARAMS, 
 		                   ALL    => 1, 
 		                   FIELDS => [0, 1, 2, 3, 4, 5, 6, 7, 8, 26] 
+
 		               } );	
 	
   print "==> check_lines\n" if ($debug > 1);
@@ -163,8 +166,15 @@
     $NAS{NAS_MNG_USER}     = $nas_row->[10]; 
     $NAS{NAS_MNG_PASSWORD} = $nas_row->[11]; 
 
+    my $USERDATA;
+
     foreach my $line (@$l) {
 	    
+	    $USERDATA->{$line->[6]}->{USER_NAME} = $line->[0],
+	    $USERDATA->{$line->[6]}->{FRAMED_ID_ADDRESS} = $line->[10];
+	    $USERDATA->{$line->[6]}->{TP_ID} = $line->[11];
+	    $USERDATA->{$line->[6]}->{NAS_PORT_ID} = $line->[2];
+	    $USERDATA->{$line->[6]}->{ACCT_SESSION_ID} = $line->[12];
 
 	    my $acct_input_octets       = $line->[5];
 	    my $acct_output_octets      = $line->[6];
@@ -242,7 +252,7 @@
           }
        } 
       elsif (defined($external_stats->{error})) {
-      	print "Error:  Login: $line->[0], NAS-IP: $NAS{NAS_IP}, Port: $line->[2], Session-ID: $acct_session_id\n" if ($debug == 1);
+      	print "Error:  Login: $line->[0], NAS-IP: $NAS{NAS_IP}, Port: $line->[2], Session-ID: $acct_session_id\n" if ($debug > 1);
       	$sessions->online_update({ USER_NAME       => $line->[0],
       		                         ACCT_SESSION_ID => $acct_session_id,
       		                         STATUS          => 5
@@ -279,12 +289,12 @@
         next if ($self->{UID} < 1);
         
         print "> Login: $RAD{USER_NAME} START: $RAD{SESSION_START} DURATION: $RAD{ACCT_SESSION_TIME}\n".
-         "UID: $self->{UID} SUM: $self->{SUM} BILL_ID: $self->{BILL_ID} TARIF_PLAN: $self->{TARIF_PLAN} TRAF_TARIF: $self->{TRAF_TARIF}\n" if ($debug == 1);
-
+         "UID: $self->{UID} SUM: $self->{SUM} BILL_ID: $self->{BILL_ID} TARIF_PLAN: $self->{TARIF_PLAN} TRAF_TARIF: $self->{TRAF_TARIF}\n" if ($debug > 1);
         
         if ( ($Billing->{PAYMENT_TYPE} == 0) 
                              && ($line->[14] + $line->[15] <= $self->{SUM}) ) {
 
+
            #Neg deposit filter
            if ($Billing->{NEG_DEPOSIT_FILTER} ne '' && $line->[14] + $line->[15] < 0) {
               print "Skip with neg deposit filter '$Billing->{NEG_DEPOSIT_FILTER}'\n" if ($debug > 1);
@@ -299,6 +309,47 @@
            	                                                      });
            print "Hanguped Login: $RAD{USER_NAME} DEPOSIT: $line->[14] CREDIT: $line->[15] SESSION_SUM: $self->{SUM} SESSION_ID: $acct_session_id\n"; # if ($debug == 1);
           }
+        if ($conf{periodic_intervals_check}) {
+              my $user = $Billing->get_timeinfo();
+
+              print "TP: $self->{TARIF_PLAN}" if ($debug > 1);
+  
+              my ($remaining_time, $ret_attr); 
+
+              ($user->{TIME_INTERVALS},
+              $user->{INTERVAL_TIME_TARIF}, 
+              $user->{INTERVAL_TRAF_TARIF}) = $Billing->time_intervals($self->{TARIF_PLAN});
+
+              ($remaining_time, $ret_attr) = $Billing->remaining_time(0, {
+                        TIME_INTERVALS      => $user->{TIME_INTERVALS},
+                        INTERVAL_TIME_TARIF => $user->{INTERVAL_TIME_TARIF},
+                        INTERVAL_TRAF_TARIF => $user->{INTERVAL_TRAF_TARIF},
+                        SESSION_START       => $user->{SESSION_START},
+                        DAY_BEGIN           => $user->{DAY_BEGIN},
+                        DAY_OF_WEEK         => $user->{DAY_OF_WEEK},
+                        DAY_OF_YEAR         => $user->{DAY_OF_YEAR},
+                        REDUCTION           => 0,
+                        POSTPAID            => 1
+              });
+
+              my $hangupmessage="";
+              print ", RT: $remaining_time\n" if ($debug > 1);
+              if ($remaining_time == -1) {
+        	        $hangupmessage="Not Allowed day";
+              }
+              elsif ($remaining_time == -2) {
+                        $hangupmessage="Not Allowed time";
+              }
+              if ($remaining_time == -1 || $remaining_time == -2) {
+                        my $ret = hangup(\%NAS, "$nas_port_id", "$line->[0]", { ACCT_SESSION_ID      => $acct_session_id,
+           	                                                       FRAMED_IP_ADDRESS    => int2ip($line->[3]),
+           	                                                       ACCT_TERMINATE_CAUSE => 15,
+           	                                                       UID                  => $self->{UID},
+           	                                                       debug                => $debug
+           	                                                      });
+                        print "Hanguped Login: $line->[0] $hangupmessage\n"; # if ($debug == 1);
+              }
+           }
        }
      }
    }