log("upnp","get_forward_list"); $db->query("SELECT * FROM upnp"); $res=array(); while ($db->next_record()) { $res[]=$db->Record; } return $res; } /* ----------------------------------------------------------------- */ /** enable a upnp port in the upnp table * @param integer the id of the port to enable * @return boolean TRUE if the port has been properly forwarded * FALSE if an error occurred */ function enable_port($id) { global $db,$err; $id=intval($id); $err->log("upnp","enable_port($id)"); $db->query("SELECT enabled FROM upnp WHERE id=$id;"); if (!$db->next_record()) { $err->raise("upnp",_("The required port is not currently defined")); return false; } if (!$db->f("enabled")) { $db->query("UPDATE upnp SET enabled=1 WHERE id=$id;"); $err->raise("upnp",_("The specified upnp port is now enabled")); return true; } $err->raise("upnp",_("The specified upnp port is already enabled")); return true; } /* ----------------------------------------------------------------- */ /** disable a upnp port in the upnp table * @param integer the id of the port to disable * @return boolean TRUE if the port has been properly forwarded * FALSE if an error occurred */ function disable_port($id) { global $db,$err; $id=intval($id); $err->log("upnp","disable_port($id)"); $db->query("SELECT enabled,mandatory FROM upnp WHERE id=$id;"); if (!$db->next_record()) { $err->raise("upnp",_("The required port is not currently defined")); return false; } if ($db->f("mandatory")) { $err->raise("upnp",_("You can't disable that mandatory port forward")); return false; } if ($db->f("enabled")) { $db->query("UPDATE upnp SET enabled=0 WHERE id=$id;"); $err->raise("upnp",_("The specified upnp port is now disabled")); return true; } $err->raise("upnp",_("The specified upnp port is already disabled")); return true; } } /* Class UPnP */