/**
  * Update traffic counters
  *
  * @param string $conn_id  The connection id for the connection to work on
  * @param int    $incoming Incoming traffic in bytes
  * @param int    $outgoing Outgoing traffic in bytes
  * @param string $errmsg   Reference of error message
  *
  * @return bool Returns always true
  */
 public function acctUpdate($conn_id, $incoming, $outgoing, &$errmsg = null)
 {
     // Call parent method
     parent::acctUpdate($conn_id, $incoming, $outgoing);
     return true;
 }
Exemplo n.º 2
0
 /**
  * Update traffic counters
  *
  * @param string $conn_id  The connection id for the connection to work on
  * @param int    $incoming Incoming traffic in bytes
  * @param int    $outgoing Outgoing traffic in bytes
  * @param string $errmsg   Reference of error message
  *
  * @return bool Returns whether successful or not
  */
 function acctUpdate($conn_id, $incoming, $outgoing, &$errmsg = null)
 {
     // Call generic traffic updater (local database)
     parent::acctUpdate($conn_id, $incoming, $outgoing);
     // Init values
     $db = AbstractDb::getObject();
     $info = null;
     $conn_id = $db->escapeString($conn_id);
     if (Dependency::check("Auth_RADIUS", $errmsg)) {
         $db->execSqlUniqueRes("SELECT CURRENT_TIMESTAMP, *, CASE WHEN ((CURRENT_TIMESTAMP - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired FROM connections JOIN users ON (users.user_id=connections.user_id) JOIN networks ON (users.account_origin = networks.network_id) WHERE connections.conn_id={$conn_id}", $info, false);
         // RADIUS accounting ping
         // Session is completely based on Database time
         $session_time = strtotime($info['now']) - strtotime($info['timestamp_in']);
         $radius_acct = new Auth_RADIUS_Acct_Update();
         $radius_acct->addServer($this->mRadius_hostname, $this->mRadius_acct_port, $this->mRadius_secret_key);
         // Specify the user for which accounting will be done
         $radius_acct->username = $info['username'];
         $racct->session_time = $session_time;
         // Set the session ID to the generated token
         $radius_acct->session_id = $info['token'];
         $status = $radius_acct->start();
         if (PEAR::isError($status)) {
             return false;
         }
         // Send traffic data along with the request
         $radius_acct->putAttribute(RADIUS_ACCT_INPUT_PACKETS, $incoming);
         $radius_acct->putAttribute(RADIUS_ACCT_OUTPUT_PACKETS, $outgoing);
         $result = $radius_acct->send();
         if (PEAR::isError($result)) {
             $errmsg = "Could not send accounting request to RADIUS server.";
             return false;
         } else {
             if ($result !== true) {
                 $radius_acct->close();
                 $errmsg = "Accounting request rejected by RADIUS server.";
                 return false;
             }
         }
         $radius_acct->close();
         return true;
     } else {
         return false;
     }
 }