Block or expire one voucher code?
-
Hi ermal,
thanx for answer. I checked the voucher.inc and the section "voucher_expire". But i don´t know how to "post a voucher with voucher_expire" variable set. Cant i do this the the voucher command?
valle
-
I'd appreciate an elaborated response myself
-
@ermal: can you give me an example, how to expire a voucher?
Valle
-
Sorry to bump this, I have the same issue where I'd like to expire a bunch of vouchers.
I thought there was a way in the GUI, but I can't seen to find it!
-
still trying to find my way, please provide a working example.
-
Me too. Maybe it will be implemented in a future version.
You can expire a whole list, but it doesn't seem there is a way to expire a single code. -
You need a client application to send a login request to authenticate and after that send a POST with the variable i said before set and the voucher you want to expire.
Normally wget with cookies can do this. -
Ahh I get it now. Like a special PHP page where you enter the code and then say "Expire" it sends a request with that var set.
Do you know it that's complicated to integrate into the GUI? If not, I'd like to do it.
Essentially, I'd just need another tab on the CP tab and then enter a list a vouchers (like on the voucher check page), that then goes and posts the above mentioned commands to the portal page, no? -
Normally there is a tab for testing vouchers and you can do there this option.
-
Yes, that's a great idea.I'll try to see if I can add a checkbox on the test voucher page for expiration.
-
many tks for the hints, I was able to code an expire voucher page (copying the test voucher page and calling voucher_expire instead):
if ($_POST) { if ($_POST['vouchers']) { $result = voucher_expire($_POST['vouchers']); echo " \n"; if ( $result) { echo ""; echo ""; } else { echo ""; echo ""; } echo " | ![](\"/themes/{$g['theme']}/images/icons/icon_pass.gif\") | Success | | ![](\"/themes/{$g['theme']}/images/icons/icon_block.gif\") | Error | "; } }
However on the portal auth log I see the following entries:
php[59817]: /status_captiveportal_expire.php: Captive portal Array passed as unset index: Array ( ) logportalauth[59817]: 37xN4hp7umY (123/68) forced to expire
and I tracked it down to the call:
captiveportal_write_db($cpdb, false, $unsetindexes);
in /etc/inc/voucher.inc
but I'm not able to get rid of that php error.
EDIT: attaching the patch related to 2.0.1-RELEASE
-
The php error came from an invalid initialized array.
See attached patch.diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc index ea723ca..a0455d2 100644 --- a/etc/inc/voucher.inc +++ b/etc/inc/voucher.inc @@ -217,7 +217,7 @@ function voucher_expire($voucher_received) { // split into an array. Useful for multiple vouchers given $a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received); $active_dirty = false; - $unsetindexes[] = array(); + $unsetindexes = array(); // go through all received vouchers, check their valid and extract // Roll# and Ticket# using the external readvoucher binary
Kind regards
Michael -
The php error came from an invalid initialized array.
See attached patch.Kind regards
MichaelThanks, made a pull request on github.