Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Block or expire one voucher code?

    Scheduled Pinned Locked Moved Captive Portal
    16 Posts 6 Posters 6.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V Offline
      valshare
      last edited by

      Hi,

      isnt there realy a way to expire or block / delete a voucher?

      Valle

      1 Reply Last reply Reply Quote 0
      • E Offline
        eri--
        last edited by

        There is if you post a voucher with 'voucher_expire' variable set.
        Check the source but its just not provided through the GUI for now.

        1 Reply Last reply Reply Quote 0
        • V Offline
          valshare
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • L Offline
            l.capriotti
            last edited by

            I'd appreciate an elaborated response myself

            1 Reply Last reply Reply Quote 0
            • V Offline
              valshare
              last edited by

              @ermal: can you give me an example, how to expire a voucher?

              Valle

              1 Reply Last reply Reply Quote 0
              • N Offline
                namezero111111
                last edited by

                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!

                1 Reply Last reply Reply Quote 0
                • L Offline
                  l.capriotti
                  last edited by

                  still trying to find my way, please provide a working example.

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    namezero111111
                    last edited by

                    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.

                    1 Reply Last reply Reply Quote 0
                    • E Offline
                      eri--
                      last edited by

                      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.

                      1 Reply Last reply Reply Quote 0
                      • N Offline
                        namezero111111
                        last edited by

                        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?

                        1 Reply Last reply Reply Quote 0
                        • E Offline
                          eri--
                          last edited by

                          Normally there is a tab for testing vouchers and you can do there this option.

                          1 Reply Last reply Reply Quote 0
                          • N Offline
                            namezero111111
                            last edited by

                            Yes, that's a great idea.I'll try to see if I can add a checkbox on the test voucher page for expiration.

                            1 Reply Last reply Reply Quote 0
                            • L Offline
                              l.capriotti
                              last edited by

                              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

                              voucherExpire.diff.txt

                              1 Reply Last reply Reply Quote 0
                              • E Offline
                                elratt0r
                                last edited by

                                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

                                voucher_array.txt

                                1 Reply Last reply Reply Quote 0
                                • B Offline
                                  bardelot
                                  last edited by

                                  @elratt0r:

                                  The php error came from an invalid initialized array.
                                  See attached patch.

                                  Kind regards
                                  Michael

                                  Thanks, made a pull request on github.

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.