diff --git a/ChangeLog b/ChangeLog index 97fb1c8e5..d53329461 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-03-20 Alexey Shchepin + + * doc/guide.tex: Updated + + * src/web/ejabberd_web.erl: Updated + + * src/web/ejabberd_http.erl: Bugfix + 2004-03-16 Alexey Shchepin * src/mod_roster.erl: Bugfix @@ -139,7 +147,7 @@ * src/mod_irc/mod_irc.erl: Likewise * src/mod_configure.erl: "jabber:iq:data" replaced with - "ejabber:config" namespace (thanks to Sergei Golovan) + "ejabberd:config" namespace (thanks to Sergei Golovan) * src/mod_disco.erl: Likewise 2004-02-12 Alexey Shchepin @@ -150,15 +158,15 @@ * src/msgs/ru.msg: Updated (thanks to Sergei Golovan) - * src/mod_irc/mod_irc.erl: Now uses "ejabber:config" namespace + * src/mod_irc/mod_irc.erl: Now uses "ejabberd:config" namespace (thanks to Sergei Golovan) * src/mod_disco.erl: Fixed disco category and type (thanks to Sergei Golovan) * src/mod_pubsub/mod_pubsub.erl: Likewise - * src/jlib.hrl: Added "ejabber:config" namespace (thanks to Sergei - Golovan) + * src/jlib.hrl: Added "ejabberd:config" namespace (thanks to + Sergei Golovan) 2004-01-27 Alexey Shchepin diff --git a/doc/guide.html b/doc/guide.html index 861864c44..e35e53870 100644 --- a/doc/guide.html +++ b/doc/guide.html @@ -129,7 +129,11 @@ Works on most of popular platforms: *nix (tested on Linux, FreeBSD and Publish-Subscribe service
  • Built-in Jabber Users Directory service based on users vCards +
  • Built-in + HTTP Polling + service
  • SSL support +
  • Support for LDAP authentification
  • Ability to interface with external components (JIT, MSN-t, Yahoo-t, etc)
  • Migration from jabberd14 is possible
  • Mostly XMPP-compliant @@ -139,12 +143,11 @@ Works on most of popular platforms: *nix (tested on Linux, FreeBSD and
  • Support for JEP-0039 (Statistics Gathering). -
  • Support for xml:lang attribute in many XML elements +
  • Support for xml:lang The misfeatures of ejabberd is:
    • -No support for external authentification -
    • No support for virtual domains +No support for virtual domains
    • No support for STARTTLS
    diff --git a/doc/guide.tex b/doc/guide.tex index d20912c81..2d552d6db 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -78,7 +78,11 @@ The main features of \ejabberd{} is: \footahref{http://www.jabber.org/jeps/jep-0060.html}{Publish-Subscribe} service \item Built-in Jabber Users Directory service based on users vCards +\item Built-in + \footahref{http://www.jabber.org/jeps/jep-0025.html}{HTTP Polling} + service \item SSL support +\item Support for LDAP authentification \item Ability to interface with external components (JIT, MSN-t, Yahoo-t, etc) \item Migration from jabberd14 is possible \item Mostly XMPP-compliant @@ -88,12 +92,11 @@ The main features of \ejabberd{} is: \item Support for \footahref{http://www.jabber.org/jeps/jep-0039.html}{JEP-0039} (Statistics Gathering). -\item Support for \ns{xml:lang} attribute in many XML elements +\item Support for \ns{xml:lang} \end{itemize} The misfeatures of \ejabberd{} is: \begin{itemize} -\item No support for external authentification \item No support for virtual domains \item No support for STARTTLS \end{itemize} diff --git a/src/web/ejabberd_http.erl b/src/web/ejabberd_http.erl index cf4427b2c..c5988d342 100644 --- a/src/web/ejabberd_http.erl +++ b/src/web/ejabberd_http.erl @@ -122,7 +122,8 @@ process_request(#state{request_method = 'GET', case ejabberd_web:process_get(Request) of El when element(1, El) == xmlelement -> make_xhtml_output(200, [], El); - {Status, Headers, El} -> + {Status, Headers, El} when + element(1, El) == xmlelement -> make_xhtml_output(Status, Headers, El); Text when is_list(Text) -> make_text_output(200, [], Text); diff --git a/src/web/ejabberd_web.erl b/src/web/ejabberd_web.erl index 5377d2563..d532f78f4 100644 --- a/src/web/ejabberd_web.erl +++ b/src/web/ejabberd_web.erl @@ -84,7 +84,8 @@ process_admin(#request{user = User, ?XE("ul", [?LI([?AC("acls/", "Access Control Lists"), ?C(" "), ?AC("acls-raw/", "(raw)")]), - ?LI([?AC("access/", "Access Rules")]), + ?LI([?AC("access/", "Access Rules"), ?C(" "), + ?AC("access-raw/", "(raw)")]), ?LI([?AC("users/", "Users")]), ?LI([?AC("nodes/", "Nodes")]), ?LI([?AC("stats/", "Statistics")]) @@ -177,6 +178,100 @@ process_admin(#request{method = Method, ]) ]); +process_admin(#request{user = User, + path = ["access-raw"], + q = Query, + lang = Lang} = Request) -> + SetAccess = + fun(Rs) -> + mnesia:transaction( + fun() -> + Os = mnesia:select(config, + [{{config, {access, '$1'}, '$2'}, + [], + ['$_']}]), + lists:foreach(fun(O) -> + mnesia:delete_object(O) + end, Os), + lists:foreach( + fun({access, Name, Rules}) -> + mnesia:write({config, + {access, Name}, + Rules}) + end, Rs) + end) + end, + Res = case lists:keysearch("access", 1, Query) of + {value, {_, String}} -> + case erl_scan:string(String) of + {ok, Tokens, _} -> + case erl_parse:parse_term(Tokens) of + {ok, Rs} -> + case SetAccess(Rs) of + {atomic, _} -> + ok; + _ -> + error + end; + _ -> + error + end; + _ -> + error + end; + _ -> + nothing + end, + Access = + lists:flatten( + io_lib:format( + "~p.", [ets:select(config, + [{{config, {access, '$1'}, '$2'}, + [], + [{{access, '$1', '$2'}}]}])])), + make_xhtml([?XC("h1", "ejabberd access rules configuration")] ++ + case Res of + ok -> [?C("submited"), ?P]; + error -> [?C("bad format"), ?P]; + nothing -> [] + end ++ + [?XAE("form", [{"method", "post"}], + [?XAC("textarea", [{"name", "access"}, + {"rows", "16"}, + {"cols", "80"}], + Access), + ?BR, + ?XA("input", [{"type", "submit"}]) + ]) + ]); + +process_admin(#request{method = Method, + user = User, + path = ["access"], + q = Query, + lang = Lang} = Request) -> + ?INFO_MSG("query: ~p", [Query]), + Res = nothing, + AccessRules = + ets:select(config, + [{{config, {access, '$1'}, '$2'}, + [], + [{{access, '$1', '$2'}}]}]), + make_xhtml([?XC("h1", "ejabberd access rules configuration")] ++ + case Res of + ok -> [?C("submited"), ?P]; + error -> [?C("bad format"), ?P]; + nothing -> [] + end ++ + [?XAE("form", [{"method", "post"}], + [access_rules_to_xhtml(AccessRules), + ?BR, + ?XA("input", [{"type", "submit"}, + {"name", "delete"}, + {"value", "Delete Selected"}]) + ]) + ]); + process_admin(#request{user = User, path = ["users"], q = Query, @@ -209,7 +304,7 @@ acls_to_xhtml(ACLs) -> lists:map( fun({acl, Name, Spec} = ACL) -> SName = atom_to_list(Name), - ID = acl_to_id(ACL), + ID = term_to_id(ACL), ?XE("tr", [?XE("td", [?XA("input", [{"type", "checkbox"}, @@ -268,8 +363,8 @@ acl_spec_select(ID, Opt) -> term_to_string(T) -> lists:flatten(io_lib:format("~1000000p", [T])). -acl_to_id(ACL) -> - jlib:encode_base64(binary_to_list(term_to_binary(ACL))). +term_to_id(T) -> + jlib:encode_base64(binary_to_list(term_to_binary(T))). acl_parse_query(Query) -> @@ -289,7 +384,7 @@ acl_parse_submit(ACLs, Query) -> lists:map( fun({acl, Name, Spec} = ACL) -> SName = atom_to_list(Name), - ID = acl_to_id(ACL), + ID = term_to_id(ACL), case {lists:keysearch("type" ++ ID, 1, Query), lists:keysearch("value" ++ ID, 1, Query)} of {{value, {_, T}}, {value, {_, V}}} -> @@ -336,12 +431,46 @@ acl_parse_delete(ACLs, Query) -> NewACLs = lists:filter( fun({acl, Name, Spec} = ACL) -> - ID = acl_to_id(ACL), + ID = term_to_id(ACL), not lists:member({"selected", ID}, Query) end, ACLs), NewACLs. +access_rules_to_xhtml(AccessRules) -> + ?XAE("table", [], + [?XE("tbody", + lists:map( + fun({access, Name, Rules} = Access) -> + SName = atom_to_list(Name), + ID = term_to_id(Access), + ?XE("tr", + [?XE("td", + [?XA("input", [{"type", "checkbox"}, + {"name", "selected"}, + {"value", ID}])]), + ?XE("td", [?AC(SName ++ "/", SName)]), + ?XC("td", term_to_string(Rules)) + ] + ) + end, AccessRules) ++ + [?XE("tr", + [?X("td"), + ?XE("td", + [?XA("input", [{"type", "text"}, + {"name", "namenew"}, + {"value", ""}])] + ), + ?XE("td", + [?XA("input", [{"type", "submit"}, + {"name", "addnew"}, + {"value", "Add New"}])]) + ] + )] + )]). + + + list_users() -> Users = ejabberd_auth:dirty_get_registered_users(),