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

    Kick all users with php command

    Scheduled Pinned Locked Moved Captive Portal
    2 Posts 2 Posters 1.1k 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.
    • M
      mendilli
      last edited by

      I am trying to write php code to kick all users one by one in a loop, with "dıscconnect" entry in portalauth.log, here is what I have so far, but it is not working.Any help is appreciated

      (I am working on pfsense 2.1.2)

      require_once("captiveportal.inc");

      $allusers = captiveportal_read_db("WHERE sessionid = '{$sessionid}'");

      foreach ($allusers as $userid)

      captiveportal_disconnect_client($userid);

      ?>

      1 Reply Last reply Reply Quote 0
      • GertjanG
        Gertjan
        last edited by

        Test this:

        
        require("captiveportal.inc");
        
        if (!is_array($config['captiveportal']))
                $config['captiveportal'] = array();
        $a_cp =& $config['captiveportal'];
        
        foreach ($a_cp as $cpkey => $cp) {
        	$cpzone = $cpkey;
        	if (!empty($cpzone))  {
        		$allusers = captiveportal_read_db("WHERE sessionid <> '0'");
        
        		foreach ($allusers as $userid) {
        		if (!empty($userid[5]))
        			// echo "Removing sessionid = ".$userid[5]."
        ";
        			captiveportal_disconnect_client($userid[5]);
        		}	
        	}
        }
        
        ?>
        
        

        This will stop all users on all interfaces (zones).

        I didn't test it myself - to many users on my portal right now  ;)

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

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