echo gettext("active"); ?> </th> <th><?php echo gettext("ready"); ?> </th> </tr> </thead> <tbody> <?php $voucherlck = lock("vouche{$cpzone}r"); $i = 0; foreach ($a_roll as $rollent) { $used = voucher_used_count($rollent['number']); $active = count(voucher_read_active_db($rollent['number']), $rollent['minutes']); $ready = $rollent['count'] - $used; /* used also count active vouchers, remove them */ $used = $used - $active; ?> <tr> <td> <?php echo htmlspecialchars($rollent['number']); ?> </td> <td> <?php echo htmlspecialchars($rollent['minutes']); ?> </td>
$len = ($rollent['count'] >> 3) + 1; // count / 8 +1 $rollent['used'] = base64_encode(str_repeat("", $len)); // 4 bitmask $rollent['active'] = array(); voucher_write_used_db($rollent['number'], $rollent['used']); voucher_write_active_db($rollent['number'], array()); // create empty DB voucher_log(LOG_INFO, sprintf(gettext('All %1$s vouchers from Roll %2$s marked unused'), $rollent['count'], $rollent['number'])); } else { // existing roll has been modified but without changing the count // read active and used DB from ramdisk and store it in XML config $rollent['used'] = base64_encode(voucher_read_used_db($rollent['number'])); $activent = array(); $db = array(); $active_vouchers = voucher_read_active_db($rollent['number'], $rollent['minutes']); foreach ($active_vouchers as $voucher => $line) { list($timestamp, $minutes) = explode(",", $line); $activent['voucher'] = $voucher; $activent['timestamp'] = $timestamp; $activent['minutes'] = $minutes; $db[] = $activent; } $rollent['active'] = $db; } unlock($voucherlck); if (isset($id) && $a_roll[$id]) { $a_roll[$id] = $rollent; } else { $a_roll[] = $rollent; }