Script help :(

  • could someone create me a script that would reset the captive portal in 0000hrs.


    If time >= 12:00AM


    since the captive portal is lacking of feature that would disconnects all users at exactly 00:00hrs, this script will help me to disconnect them at that specific time.



    what is that for?, is that the command to reboot/reset the CP?

    thanks and more power

  • Not the best idea to restart the captive portal - suggest you run a 'prune' of users at a specific time.

  • @cordeos

    thank you so much for giving time at my noob queries :)

    sir, may you enhance this code

    $database = captiveportal_read_db();
    $no_users = count($database);
    for ($i = 0; $i < $no_users; $i++) {
    	if database(?) = expireuseraccount
    //do this every 0001hrs

    that is more likely I wanted to achieve.

    thanks again.

    another thing

    //erase expired accounts
       if (is_array($userdb)) {
           $moddb = false;
           for ($i = 0; $i < count($userdb); $i++) {
               if ($userdb[$i]['expirationdate'] && (strtotime("-1 day") > strtotime($userdb[$i]['expirationdate']))) {
                   $moddb = true;
           if ($moddb)

    $userdb = &$config['captiveportal']['user'];

    for ($i = 0; $i < count($userdb); $i++) {
               if (($userdb[$i]['name'] == $_POST['auth_user']) && ($userdb[$i]['password'] == md5($_POST['auth_pass']))) {
                   $loginok = true;

    notice the red line, is it possible to put that code?

  • @all php coders

    please help me with this code, I want to run it at cron so that it would terminate logged-on clients if their accounts is expired at 00:00hrs

    radius_database = /sr/local/etc/raddb/users  //this is the record of all radius users 
    cp_database = /var/db/captiveporta.db        //this is the record of logged-on clients
    radius_user = count(radius_database)
    cp_users = count(cp_database)
    for i = 1 to len(radius_user)
    	if radius_user[i][expiration] = today
    		for ii = 1 to len(cp_users)
    			if radius_user[i][username]=cp_users[ii][username]
    		next ii
    next i
    close databases
    thanks and more power

  • Suggest you use the script provided in your other post,27717.0.html

    That script will achieve your requirements. You may need to just adjust the radius call to use your local radius user file (instead of radius service call)

Log in to reply