Exemplo n.º 1
0
 /**
  * @param string $cpzonename zone name
  * @param string $sessionid session id
  * @return boolean false for invalid request
  */
 private function disconnectSession($cpzonename, $sessionid)
 {
     $zoneid = -1;
     foreach ($this->config->object()->captiveportal->children() as $zone => $zoneobj) {
         if ($zone == $cpzonename) {
             $zoneid = $zoneobj->zoneid;
         }
     }
     if ($zoneid == -1) {
         // not a valid zone
         return false;
     }
     $db = new DB($cpzonename);
     $db_clients = $db->listClients(array("sessionid" => $sessionid));
     $ipfw_tables = $this->rules->getAuthUsersTables($zoneid);
     if (sizeof($db_clients) > 0) {
         if ($db_clients[0]->ip != null) {
             // only handle disconnect if we can find a client in our database
             $exec_commands[] = "/sbin/ipfw table " . $ipfw_tables["in"] . " delete " . $db_clients[0]->ip;
             $exec_commands[] = "/sbin/ipfw table " . $ipfw_tables["out"] . " delete " . $db_clients[0]->ip;
             $this->shell->exec($exec_commands);
             // TODO: cleanup dummynet pipes $db_clients[0]->pipeno_in/out
             // TODO: log removal
             // ( was : captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "DISCONNECT");)
         }
         $db->removeSession($sessionid);
     }
     return true;
 }