From ce274e4545109efd712ac4e23cf99c8d4bb4d095 Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Tue, 15 Sep 2015 11:55:35 -0500 Subject: [PATCH] Check if our version of roll data is valid and if necessary, initialize the database. This fix the case where the database is not initialized because the used field in backup file is empty. Fix the issue #5113. --- etc/inc/voucher.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc index 00cb397b30..863cc171e5 100644 --- a/etc/inc/voucher.inc +++ b/etc/inc/voucher.inc @@ -557,6 +557,9 @@ function voucher_configure_zone($sync = false) { foreach ($config['voucher'][$cpzone]['roll'] as $rollent) { $roll = $rollent['number']; + $len = ($rollent['count'] >> 3) + 1; + if (strlen(base64_decode($rollent['used'])) != $len) + $rollent['used'] = base64_encode(str_repeat("\000", $len)); voucher_write_used_db($roll, $rollent['used']); $minutes = $rollent['minutes']; $active_vouchers = array();