public function setVoucher($attributes) { if (isset($attributes['MaxMb'])) { $attributes['MaxOctets'] = Util::bigIntVal($attributes['MaxMb'] * 1024 * 1024); unset($attributes['MaxMb']); } if (isset($attributes['MaxTime'])) { $attributes['MaxSeconds'] = $attributes['MaxTime'] * 60; unset($attributes['MaxTime']); } $attributes['VoucherType'] = 0; if ($attributes['InitVoucher']) { $attributes['VoucherType'] = 1 | $attributes['VoucherType']; } if ($attributes['TopupVoucher']) { $attributes['VoucherType'] = 2 | $attributes['VoucherType']; } $fields = array('VoucherName' => $attributes['VoucherName'], 'VoucherLabel' => $attributes['VoucherLabel'], 'VoucherPrice' => $attributes['VoucherPrice'] + 0, 'VoucherGroup' => $attributes['VoucherGroup'], 'MaxOctets' => @$attributes['MaxOctets'], 'MaxSeconds' => @$attributes['MaxSeconds'], 'Description' => @$attributes['Description'], 'VoucherType' => $attributes['VoucherType']); $query = $this->radmin->prepare("INSERT INTO vouchers\n (VoucherName, VoucherLabel, VoucherPrice, VoucherGroup,\n MaxOctets, MaxSeconds, Description, VoucherType)\n VALUES\n (:VoucherName, :VoucherLabel, :VoucherPrice, :VoucherGroup,\n :MaxOctets, :MaxSeconds, :Description, :VoucherType)\n ON DUPLICATE KEY UPDATE\n VoucherLabel = :VoucherLabel,\n VoucherPrice = :VoucherPrice,\n VoucherGroup = :VoucherGroup,\n MaxOctets = :MaxOctets,\n MaxSeconds = :MaxSeconds,\n Description = :Description,\n VoucherType =:VoucherType"); $result = $query->execute($fields); if ($result === false) { ErrorHandling::fatalDatabaseError(T_('Adding Voucher query failed: '), $result); } \AdminLog::getInstance()->log("Voucher " . $attributes['VoucherName'] . "\n updated settings"); return $result; }
public function setUserDatalimit($username, $limitmb) { $datalimitoctets = $limitmb * 1024 * 1024; $fields = array('Username' => array('value' => $username, 'key' => true), 'Attribute' => array('value' => 'Max-Octets', 'key' => true), 'op' => array('value' => ':='), 'Value' => array('value' => \Grase\Util::bigIntVal($datalimitoctets))); $result = $this->db->replace('radcheck', $fields); if (PEAR::isError($result)) { \Grase\ErrorHandling::fatalDatabaseError(T_('Setting User Datalimit Query Failed: '), $result); } return $result; }
function clean_int($number) { if (!is_numeric(clean_number($number))) { return clean_number($number); } return \Grase\Util::bigIntVal(clean_number($number)); //ereg_replace("[^0-9]", "", \Grase\Clean::text($number)); }