X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND%2FIRC%2FAccess.pm;fp=ND%2FIRC%2FAccess.pm;h=91b800253d8cd999eca95f756db4a93ef37946d8;hb=55cc621bec16d80555e9e588c731505a8b04e1a9;hp=0000000000000000000000000000000000000000;hpb=98378b594064426cdbc06b30a58553195d8cf8ec;p=ndwebbie.git diff --git a/ND/IRC/Access.pm b/ND/IRC/Access.pm new file mode 100644 index 0000000..91b8002 --- /dev/null +++ b/ND/IRC/Access.pm @@ -0,0 +1,65 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ +package ND::IRC::Access; +use strict; +use warnings; +require Exporter; + +our @ISA = qw/Exporter/; + +our @EXPORT = qw/officer dc bc hc scanner intel masterop masterinvite/; + +sub officer { + return groupmember("HO"); +}; +sub dc { + return groupmember("HD"); +}; +sub bc { + return groupmember("HB"); +}; +sub hc { + return groupmember("H"); +}; +sub scanner { + return groupmember("HS"); +}; +sub intel { + return groupmember("HI"); +}; + +sub masterop { + return groupmember("HO"); +}; +sub masterinvite { + return groupmember("H"); +}; + +sub groupmember { + my ($groups) = @_; + $groups = join ",", map {"'$_'"} split //, $groups; + my $f = $ND::DBH->prepare("SELECT username FROM users NATURAL JOIN groupmembers NATURAL JOIN groups WHERE flag IN ('T',$groups) AND hostmask ILIKE ?"); + $f->execute($ND::address); + if ($f->fetchrow()){ + return 1; + } + return 0; +}; + +1;