mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
* (all): Updated win32 stuff (thanks to Sergei Golovan)
* src/web/ejabberd_web.erl: Added interface for access rules configuration SVN Revision: 221
This commit is contained in:
parent
2f47b7edd9
commit
b75fb79677
@ -1,3 +1,10 @@
|
|||||||
|
2004-03-21 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* (all): Updated win32 stuff (thanks to Sergei Golovan)
|
||||||
|
|
||||||
|
* src/web/ejabberd_web.erl: Added interface for access rules
|
||||||
|
configuration
|
||||||
|
|
||||||
2004-03-20 Alexey Shchepin <alexey@sevcom.net>
|
2004-03-20 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* doc/guide.tex: Updated
|
* doc/guide.tex: Updated
|
||||||
|
@ -127,14 +127,17 @@ To compile \ejabberd{} in MS Windows environment, you will need the following
|
|||||||
packages:
|
packages:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item MS Visual C++~6.0 Compiler
|
\item MS Visual C++~6.0 Compiler
|
||||||
\item \footahref{http://www.erlang.org/download/otp_win32_R8B-2.exe}{Erlang
|
\item \footahref{http://www.erlang.org/download/otp_win32_R9C-0.exe}{Erlang emulator version~5.3}
|
||||||
emulator version~5.1.2}
|
|
||||||
\item \footahref{http://prdownloads.sourceforge.net/expat/expat_win32bin_1_95_6.exe?download}{Expat~1.95.6}
|
\item \footahref{http://prdownloads.sourceforge.net/expat/expat_win32bin_1_95_6.exe?download}{Expat~1.95.6}
|
||||||
\item \footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-lib.exe?download}{Iconv~1.8} (optional)
|
\item
|
||||||
|
\footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-bin.exe?download}{Iconv~1.8
|
||||||
|
binaries} and
|
||||||
|
\footahref{http://prdownloads.sourceforge.net/gnuwin32/libiconv-1.8-1-lib.exe?download}{Iconv~1.8
|
||||||
|
development libraries}
|
||||||
|
(optional)
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\subsection{Obtaining}
|
\subsection{Obtaining}
|
||||||
\label{sec:obtaining}
|
\label{sec:obtaining}
|
||||||
|
|
||||||
|
@ -3,10 +3,29 @@ include Makefile.inc
|
|||||||
|
|
||||||
EXPAT_DIR="c:\progra~1\expat-1.95.6"
|
EXPAT_DIR="c:\progra~1\expat-1.95.6"
|
||||||
|
|
||||||
ALL : expat_erl.dll
|
ALL : expat_erl.dll compile-beam all-recursive
|
||||||
|
|
||||||
|
all-recursive :
|
||||||
|
cd eldap
|
||||||
|
nmake -nologo -f Makefile.win32
|
||||||
|
cd ..\mod_irc
|
||||||
|
nmake -nologo -f Makefile.win32
|
||||||
|
cd ..\mod_muc
|
||||||
|
nmake -nologo -f Makefile.win32
|
||||||
|
cd ..\mod_pubsub
|
||||||
|
nmake -nologo -f Makefile.win32
|
||||||
|
cd ..\stringprep
|
||||||
|
nmake -nologo -f Makefile.win32
|
||||||
|
cd ..\web
|
||||||
|
nmake -nologo -f Makefile.win32
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
compile-beam :
|
||||||
erl -s make all report -noinput -s erlang halt
|
erl -s make all report -noinput -s erlang halt
|
||||||
|
|
||||||
CLEAN :
|
CLEAN : clean-recursive clean-local
|
||||||
|
|
||||||
|
clean-local :
|
||||||
-@erase expat_erl.obj
|
-@erase expat_erl.obj
|
||||||
-@erase vc60.idb
|
-@erase vc60.idb
|
||||||
-@erase expat_erl.dll
|
-@erase expat_erl.dll
|
||||||
@ -15,8 +34,23 @@ CLEAN :
|
|||||||
-@erase expat_erl.pch
|
-@erase expat_erl.pch
|
||||||
-@erase *.beam
|
-@erase *.beam
|
||||||
|
|
||||||
|
clean-recursive :
|
||||||
|
cd eldap
|
||||||
|
nmake -nologo -f Makefile.win32 clean
|
||||||
|
cd ..\mod_irc
|
||||||
|
nmake -nologo -f Makefile.win32 clean
|
||||||
|
cd ..\mod_muc
|
||||||
|
nmake -nologo -f Makefile.win32 clean
|
||||||
|
cd ..\mod_pubsub
|
||||||
|
nmake -nologo -f Makefile.win32 clean
|
||||||
|
cd ..\stringprep
|
||||||
|
nmake -nologo -f Makefile.win32 clean
|
||||||
|
cd ..\web
|
||||||
|
nmake -nologo -f Makefile.win32 clean
|
||||||
|
cd ..
|
||||||
|
|
||||||
CPP=cl.exe
|
CPP=cl.exe
|
||||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(EXPAT_DIR)\source\lib" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpexpat_erl.pch /YX /FD /c
|
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(EXPAT_DIR)\source\lib" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpexpat_erl.pch /YX /FD /c
|
||||||
|
|
||||||
.c.obj::
|
.c.obj::
|
||||||
$(CPP) @<<
|
$(CPP) @<<
|
||||||
@ -24,7 +58,7 @@ CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\in
|
|||||||
<<
|
<<
|
||||||
|
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
LINK32_FLAGS=kernel32.lib "$(ERLANG_DIR)\usr\lib\erl_dll.lib" "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(EXPAT_DIR)\libs\libexpat.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:expat_erl.dll
|
LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(EXPAT_DIR)\libs\libexpat.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:expat_erl.dll /nodefaultlib:libcmt
|
||||||
LINK32_OBJS=expat_erl.obj
|
LINK32_OBJS=expat_erl.obj
|
||||||
|
|
||||||
expat_erl.dll : $(LINK32_OBJS)
|
expat_erl.dll : $(LINK32_OBJS)
|
||||||
|
24
src/eldap/Makefile.win32
Normal file
24
src/eldap/Makefile.win32
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
include ..\Makefile.inc
|
||||||
|
|
||||||
|
OUTDIR = ..
|
||||||
|
EFLAGS = -I .. -pz ..
|
||||||
|
|
||||||
|
OBJS = \
|
||||||
|
$(OUTDIR)\eldap.beam \
|
||||||
|
$(OUTDIR)\ELDAPv3.beam
|
||||||
|
|
||||||
|
ALL : $(OBJS)
|
||||||
|
|
||||||
|
CLEAN :
|
||||||
|
-@erase ELDAPv3.asn1db ELDAPv3.erl ELDAPv3.hrl
|
||||||
|
-@erase $(OBJS)
|
||||||
|
|
||||||
|
ELDAPv3.erl : ELDAPv3.asn
|
||||||
|
erlc -bber_bin -W $(EFLAGS) ELDAPv3.asn
|
||||||
|
|
||||||
|
$(OUTDIR)\eldap.beam : eldap.erl ELDAPv3.erl
|
||||||
|
erlc -W $(EFLAGS) -o $(OUTDIR) eldap.erl
|
||||||
|
|
||||||
|
$(OUTDIR)\ELDAPv3.beam : ELDAPv3.erl
|
||||||
|
erlc -W $(EFLAGS) -o $(OUTDIR) ELDAPv3.erl
|
@ -1,6 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <erl_driver.h>
|
#include <erl_driver.h>
|
||||||
#include <ei.h>
|
#include <ei.h>
|
||||||
#include <expat.h>
|
#include <expat.h>
|
||||||
|
@ -20,7 +20,7 @@ CLEAN :
|
|||||||
-@erase iconv_erl.obj
|
-@erase iconv_erl.obj
|
||||||
-@erase iconv_erl.pch
|
-@erase iconv_erl.pch
|
||||||
-@erase vc60.idb
|
-@erase vc60.idb
|
||||||
-@erase *.beam
|
-@erase $(OBJS)
|
||||||
|
|
||||||
$(OUTDIR)\iconv.beam : iconv.erl
|
$(OUTDIR)\iconv.beam : iconv.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) iconv.erl
|
erlc -W $(EFLAGS) -o $(OUTDIR) iconv.erl
|
||||||
@ -32,7 +32,7 @@ $(OUTDIR)\mod_irc_connection.beam : mod_irc_connection.erl
|
|||||||
erlc -W $(EFLAGS) -o $(OUTDIR) mod_irc_connection.erl
|
erlc -W $(EFLAGS) -o $(OUTDIR) mod_irc_connection.erl
|
||||||
|
|
||||||
CPP=cl.exe
|
CPP=cl.exe
|
||||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(GNUWIN_DIR)\include" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpiconv_erl.pch /YX /FD /c
|
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /I "$(GNUWIN_DIR)\include" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpiconv_erl.pch /YX /FD /c
|
||||||
|
|
||||||
.c.obj::
|
.c.obj::
|
||||||
$(CPP) @<<
|
$(CPP) @<<
|
||||||
@ -40,7 +40,7 @@ CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\in
|
|||||||
<<
|
<<
|
||||||
|
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
LINK32_FLAGS=kernel32.lib "$(ERLANG_DIR)\usr\lib\erl_dll.lib" "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(GNUWIN_DIR)\lib\libiconv.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\iconv_erl.dll
|
LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" "$(GNUWIN_DIR)\lib\libiconv.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\iconv_erl.dll /nodefaultlib:libcmt
|
||||||
LINK32_OBJS=iconv_erl.obj
|
LINK32_OBJS=iconv_erl.obj
|
||||||
|
|
||||||
$(OUTDIR)\iconv_erl.dll : $(LINK32_OBJS)
|
$(OUTDIR)\iconv_erl.dll : $(LINK32_OBJS)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <erl_driver.h>
|
#include <erl_driver.h>
|
||||||
#include <ei.h>
|
#include <ei.h>
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
@ -11,7 +11,7 @@ OBJS = \
|
|||||||
ALL : $(OBJS)
|
ALL : $(OBJS)
|
||||||
|
|
||||||
CLEAN :
|
CLEAN :
|
||||||
-@erase *.beam
|
-@erase $(OBJS)
|
||||||
|
|
||||||
$(OUTDIR)\mod_muc.beam : mod_muc.erl
|
$(OUTDIR)\mod_muc.beam : mod_muc.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) mod_muc.erl
|
erlc -W $(EFLAGS) -o $(OUTDIR) mod_muc.erl
|
||||||
|
@ -10,7 +10,7 @@ OBJS = \
|
|||||||
ALL : $(OBJS)
|
ALL : $(OBJS)
|
||||||
|
|
||||||
CLEAN :
|
CLEAN :
|
||||||
-@erase *.beam
|
-@erase $(OBJS)
|
||||||
|
|
||||||
$(OUTDIR)\mod_pubsub.beam : mod_pubsub.erl
|
$(OUTDIR)\mod_pubsub.beam : mod_pubsub.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) mod_pubsub.erl
|
erlc -W $(EFLAGS) -o $(OUTDIR) mod_pubsub.erl
|
||||||
|
@ -19,7 +19,7 @@ $(OUTDIR)\stringprep.beam : stringprep.erl
|
|||||||
erlc -W $(EFLAGS) -o $(OUTDIR) stringprep.erl
|
erlc -W $(EFLAGS) -o $(OUTDIR) stringprep.erl
|
||||||
|
|
||||||
CPP=cl.exe
|
CPP=cl.exe
|
||||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpstringprep_drv.pch /YX /FD /c
|
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpstringprep_drv.pch /YX /FD /c
|
||||||
|
|
||||||
.c.obj::
|
.c.obj::
|
||||||
$(CPP) @<<
|
$(CPP) @<<
|
||||||
@ -27,7 +27,7 @@ CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\in
|
|||||||
<<
|
<<
|
||||||
|
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
LINK32_FLAGS=kernel32.lib "$(ERLANG_DIR)\usr\lib\erl_dll.lib" "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\stringprep_drv.dll
|
LINK32_FLAGS=kernel32.lib "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\stringprep_drv.dll /nodefaultlib:libcmt
|
||||||
|
|
||||||
LINK32_OBJS=stringprep_drv.obj
|
LINK32_OBJS=stringprep_drv.obj
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <erl_driver.h>
|
#include <erl_driver.h>
|
||||||
#include <ei.h>
|
#include <ei.h>
|
||||||
|
|
||||||
|
24
src/web/Makefile.win32
Normal file
24
src/web/Makefile.win32
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
include ..\Makefile.inc
|
||||||
|
|
||||||
|
OUTDIR = ..
|
||||||
|
EFLAGS = -I .. -pz ..
|
||||||
|
|
||||||
|
OBJS = \
|
||||||
|
$(OUTDIR)\ejabberd_http.beam \
|
||||||
|
$(OUTDIR)\ejabberd_web.beam \
|
||||||
|
$(OUTDIR)\ejabberd_http_poll.beam
|
||||||
|
|
||||||
|
ALL : $(OBJS)
|
||||||
|
|
||||||
|
CLEAN :
|
||||||
|
-@erase $(OBJS)
|
||||||
|
|
||||||
|
$(OUTDIR)\ejabberd_http.beam : ejabberd_http.erl
|
||||||
|
erlc -W $(EFLAGS) -o $(OUTDIR) ejabberd_http.erl
|
||||||
|
|
||||||
|
$(OUTDIR)\ejabberd_web.beam : ejabberd_web.erl
|
||||||
|
erlc -W $(EFLAGS) -o $(OUTDIR) ejabberd_web.erl
|
||||||
|
|
||||||
|
$(OUTDIR)\ejabberd_http_poll.beam : ejabberd_http_poll.erl
|
||||||
|
erlc -W $(EFLAGS) -o $(OUTDIR) ejabberd_http_poll.erl
|
@ -43,7 +43,10 @@ make_xhtml(Els) ->
|
|||||||
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
|
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
|
||||||
-define(P, ?X("p")).
|
-define(P, ?X("p")).
|
||||||
-define(BR, ?X("br")).
|
-define(BR, ?X("br")).
|
||||||
|
-define(INPUT(Type, Name, Value),
|
||||||
|
?XA("input", [{"type", Type},
|
||||||
|
{"name", Name},
|
||||||
|
{"value", Value}])).
|
||||||
|
|
||||||
|
|
||||||
process_get(#request{user = User,
|
process_get(#request{user = User,
|
||||||
@ -130,7 +133,7 @@ process_admin(#request{user = User,
|
|||||||
{"cols", "80"}],
|
{"cols", "80"}],
|
||||||
ACLs),
|
ACLs),
|
||||||
?BR,
|
?BR,
|
||||||
?XA("input", [{"type", "submit"}])
|
?INPUT("submit", "", "")
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -168,13 +171,9 @@ process_admin(#request{method = Method,
|
|||||||
[?XAE("form", [{"method", "post"}],
|
[?XAE("form", [{"method", "post"}],
|
||||||
[acls_to_xhtml(ACLs),
|
[acls_to_xhtml(ACLs),
|
||||||
?BR,
|
?BR,
|
||||||
?XA("input", [{"type", "submit"},
|
?INPUT("submit", "delete", "Delete Selected"),
|
||||||
{"name", "delete"},
|
|
||||||
{"value", "Delete Selected"}]),
|
|
||||||
?C(" "),
|
?C(" "),
|
||||||
?XA("input", [{"type", "submit"},
|
?INPUT("submit", "submit", "Submit")
|
||||||
{"name", "submit"},
|
|
||||||
{"value", "Submit"}])
|
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -241,7 +240,7 @@ process_admin(#request{user = User,
|
|||||||
{"cols", "80"}],
|
{"cols", "80"}],
|
||||||
Access),
|
Access),
|
||||||
?BR,
|
?BR,
|
||||||
?XA("input", [{"type", "submit"}])
|
?INPUT("submit", "", "")
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -251,7 +250,17 @@ process_admin(#request{method = Method,
|
|||||||
q = Query,
|
q = Query,
|
||||||
lang = Lang} = Request) ->
|
lang = Lang} = Request) ->
|
||||||
?INFO_MSG("query: ~p", [Query]),
|
?INFO_MSG("query: ~p", [Query]),
|
||||||
Res = nothing,
|
Res = case Method of
|
||||||
|
'POST' ->
|
||||||
|
case catch access_parse_query(Query) of
|
||||||
|
{'EXIT', _} ->
|
||||||
|
error;
|
||||||
|
ok ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
nothing
|
||||||
|
end,
|
||||||
AccessRules =
|
AccessRules =
|
||||||
ets:select(config,
|
ets:select(config,
|
||||||
[{{config, {access, '$1'}, '$2'},
|
[{{config, {access, '$1'}, '$2'},
|
||||||
@ -266,9 +275,47 @@ process_admin(#request{method = Method,
|
|||||||
[?XAE("form", [{"method", "post"}],
|
[?XAE("form", [{"method", "post"}],
|
||||||
[access_rules_to_xhtml(AccessRules),
|
[access_rules_to_xhtml(AccessRules),
|
||||||
?BR,
|
?BR,
|
||||||
?XA("input", [{"type", "submit"},
|
?INPUT("submit", "delete", "Delete Selected")
|
||||||
{"name", "delete"},
|
])
|
||||||
{"value", "Delete Selected"}])
|
]);
|
||||||
|
|
||||||
|
process_admin(#request{method = Method,
|
||||||
|
user = User,
|
||||||
|
path = ["access", SName],
|
||||||
|
q = Query,
|
||||||
|
lang = Lang} = Request) ->
|
||||||
|
?INFO_MSG("query: ~p", [Query]),
|
||||||
|
Name = list_to_atom(SName),
|
||||||
|
Res = case lists:keysearch("rules", 1, Query) of
|
||||||
|
{value, {_, String}} ->
|
||||||
|
case parse_access_rule(String) of
|
||||||
|
{ok, Rs} ->
|
||||||
|
ejabberd_config:add_global_option(
|
||||||
|
{access, Name}, Rs),
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
error
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
nothing
|
||||||
|
end,
|
||||||
|
Rules = case ejabberd_config:get_global_option({access, Name}) of
|
||||||
|
undefined ->
|
||||||
|
[];
|
||||||
|
Rs1 ->
|
||||||
|
Rs1
|
||||||
|
end,
|
||||||
|
make_xhtml([?XC("h1",
|
||||||
|
"ejabberd access rule '" ++ SName ++ "' configuration")] ++
|
||||||
|
case Res of
|
||||||
|
ok -> [?C("submited"), ?P];
|
||||||
|
error -> [?C("bad format"), ?P];
|
||||||
|
nothing -> []
|
||||||
|
end ++
|
||||||
|
[?XAE("form", [{"method", "post"}],
|
||||||
|
[access_rule_to_xhtml(Rules),
|
||||||
|
?BR,
|
||||||
|
?INPUT("submit", "submit", "")
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -306,28 +353,20 @@ acls_to_xhtml(ACLs) ->
|
|||||||
SName = atom_to_list(Name),
|
SName = atom_to_list(Name),
|
||||||
ID = term_to_id(ACL),
|
ID = term_to_id(ACL),
|
||||||
?XE("tr",
|
?XE("tr",
|
||||||
[?XE("td",
|
[?XE("td", [?INPUT("checkbox", "selected", ID)]),
|
||||||
[?XA("input", [{"type", "checkbox"},
|
|
||||||
{"name", "selected"},
|
|
||||||
{"value", ID}])]),
|
|
||||||
?XC("td", SName)] ++
|
?XC("td", SName)] ++
|
||||||
acl_spec_to_xhtml(ID, Spec)
|
acl_spec_to_xhtml(ID, Spec)
|
||||||
)
|
)
|
||||||
end, ACLs) ++
|
end, ACLs) ++
|
||||||
[?XE("tr",
|
[?XE("tr",
|
||||||
[?X("td"),
|
[?X("td"),
|
||||||
?XE("td",
|
?XE("td", [?INPUT("text", "namenew", "")])
|
||||||
[?XA("input", [{"type", "text"},
|
] ++
|
||||||
{"name", "namenew"},
|
|
||||||
{"value", ""}])]
|
|
||||||
)] ++
|
|
||||||
acl_spec_to_xhtml("new", {user, ""})
|
acl_spec_to_xhtml("new", {user, ""})
|
||||||
)]
|
)]
|
||||||
)]).
|
)]).
|
||||||
|
|
||||||
-define(ACLINPUT(Text), ?XE("td", [?XA("input", [{"type", "text"},
|
-define(ACLINPUT(Text), ?XE("td", [?INPUT("text", "value" ++ ID, Text)])).
|
||||||
{"name", "value" ++ ID},
|
|
||||||
{"value", Text}])])).
|
|
||||||
|
|
||||||
acl_spec_to_text({user, U}) ->
|
acl_spec_to_text({user, U}) ->
|
||||||
{user, U};
|
{user, U};
|
||||||
@ -445,10 +484,7 @@ access_rules_to_xhtml(AccessRules) ->
|
|||||||
SName = atom_to_list(Name),
|
SName = atom_to_list(Name),
|
||||||
ID = term_to_id(Access),
|
ID = term_to_id(Access),
|
||||||
?XE("tr",
|
?XE("tr",
|
||||||
[?XE("td",
|
[?XE("td", [?INPUT("checkbox", "selected", ID)]),
|
||||||
[?XA("input", [{"type", "checkbox"},
|
|
||||||
{"name", "selected"},
|
|
||||||
{"value", ID}])]),
|
|
||||||
?XE("td", [?AC(SName ++ "/", SName)]),
|
?XE("td", [?AC(SName ++ "/", SName)]),
|
||||||
?XC("td", term_to_string(Rules))
|
?XC("td", term_to_string(Rules))
|
||||||
]
|
]
|
||||||
@ -456,19 +492,84 @@ access_rules_to_xhtml(AccessRules) ->
|
|||||||
end, AccessRules) ++
|
end, AccessRules) ++
|
||||||
[?XE("tr",
|
[?XE("tr",
|
||||||
[?X("td"),
|
[?X("td"),
|
||||||
?XE("td",
|
?XE("td", [?INPUT("text", "namenew", "")]),
|
||||||
[?XA("input", [{"type", "text"},
|
?XE("td", [?INPUT("submit", "addnew", "Add New")])
|
||||||
{"name", "namenew"},
|
|
||||||
{"value", ""}])]
|
|
||||||
),
|
|
||||||
?XE("td",
|
|
||||||
[?XA("input", [{"type", "submit"},
|
|
||||||
{"name", "addnew"},
|
|
||||||
{"value", "Add New"}])])
|
|
||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
)]).
|
)]).
|
||||||
|
|
||||||
|
access_parse_query(Query) ->
|
||||||
|
AccessRules =
|
||||||
|
ets:select(config,
|
||||||
|
[{{config, {access, '$1'}, '$2'},
|
||||||
|
[],
|
||||||
|
[{{access, '$1', '$2'}}]}]),
|
||||||
|
case lists:keysearch("addnew", 1, Query) of
|
||||||
|
{value, _} ->
|
||||||
|
access_parse_addnew(AccessRules, Query);
|
||||||
|
_ ->
|
||||||
|
case lists:keysearch("delete", 1, Query) of
|
||||||
|
{value, _} ->
|
||||||
|
access_parse_delete(AccessRules, Query)
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
|
access_parse_addnew(AccessRules, Query) ->
|
||||||
|
case lists:keysearch("namenew", 1, Query) of
|
||||||
|
{value, {_, String}} when String /= "" ->
|
||||||
|
Name = list_to_atom(String),
|
||||||
|
ejabberd_config:add_global_option({access, Name}, []),
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
|
access_parse_delete(AccessRules, Query) ->
|
||||||
|
lists:foreach(
|
||||||
|
fun({access, Name, _Rules} = AccessRule) ->
|
||||||
|
ID = term_to_id(AccessRule),
|
||||||
|
case lists:member({"selected", ID}, Query) of
|
||||||
|
true ->
|
||||||
|
mnesia:transaction(
|
||||||
|
fun() ->
|
||||||
|
mnesia:delete({config, {access, Name}})
|
||||||
|
end);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end
|
||||||
|
end, AccessRules),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
access_rule_to_xhtml(Rules) ->
|
||||||
|
Text = lists:flatmap(
|
||||||
|
fun({Access, ACL} = Rule) ->
|
||||||
|
SAccess = atom_to_list(Access),
|
||||||
|
SACL = atom_to_list(ACL),
|
||||||
|
SAccess ++ "\t" ++ SACL ++ "\n"
|
||||||
|
end, Rules),
|
||||||
|
?XAC("textarea", [{"name", "rules"},
|
||||||
|
{"rows", "16"},
|
||||||
|
{"cols", "80"}],
|
||||||
|
Text).
|
||||||
|
|
||||||
|
parse_access_rule(Text) ->
|
||||||
|
Strings = string:tokens(Text, "\r\n"),
|
||||||
|
case catch lists:flatmap(
|
||||||
|
fun(String) ->
|
||||||
|
case string:tokens(String, "\s\t") of
|
||||||
|
[Access, ACL] ->
|
||||||
|
[{list_to_atom(Access), list_to_atom(ACL)}];
|
||||||
|
[] ->
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end, Strings) of
|
||||||
|
{'EXIT', _Reason} ->
|
||||||
|
error;
|
||||||
|
Rs ->
|
||||||
|
{ok, Rs}
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user