mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-25 14:24:55 +02:00
* src/web/ejabberd_web_admin.erl: Updated
SVN Revision: 228
This commit is contained in:
parent
4760ff3201
commit
a16524151c
@ -1,3 +1,7 @@
|
|||||||
|
2004-05-04 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/web/ejabberd_web_admin.erl: Updated
|
||||||
|
|
||||||
2004-05-01 Alexey Shchepin <alexey@sevcom.net>
|
2004-05-01 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/web/ejabberd_http.erl: 'Accept-Language' header support
|
* src/web/ejabberd_http.erl: 'Accept-Language' header support
|
||||||
|
@ -30,11 +30,12 @@
|
|||||||
|
|
||||||
|
|
||||||
-define(XHTML_DOCTYPE,
|
-define(XHTML_DOCTYPE,
|
||||||
|
"<?xml version='1.0'?>\n"
|
||||||
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
|
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
|
||||||
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n").
|
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n").
|
||||||
|
|
||||||
-define(HTML_DOCTYPE,
|
-define(HTML_DOCTYPE,
|
||||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">").
|
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n").
|
||||||
|
|
||||||
|
|
||||||
start(SockData, Opts) ->
|
start(SockData, Opts) ->
|
||||||
|
@ -46,40 +46,18 @@
|
|||||||
make_xhtml(Els, Lang) ->
|
make_xhtml(Els, Lang) ->
|
||||||
{200, [html],
|
{200, [html],
|
||||||
{xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"},
|
{xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"},
|
||||||
{"xml:lang", "en"},
|
{"xml:lang", Lang},
|
||||||
{"lang", "en"}],
|
{"lang", Lang}],
|
||||||
[{xmlelement, "head", [],
|
[{xmlelement, "head", [],
|
||||||
[{xmlelement, "meta", [{"http-equiv", "Content-Type"},
|
[{xmlelement, "meta", [{"http-equiv", "Content-Type"},
|
||||||
{"content", "text/html; charset=utf-8"}], []},
|
{"content", "text/html; charset=utf-8"}], []},
|
||||||
{xmlelement, "link", [{"href", "/admin/style.css"},
|
{xmlelement, "link", [{"href", "/admin/style.css"},
|
||||||
{"type", "text/css"},
|
{"type", "text/css"},
|
||||||
{"rel", "StyleSheet"}], []}]},
|
{"rel", "stylesheet"}], []}]},
|
||||||
{xmlelement, "body",
|
?XE("body",
|
||||||
[{"topmargin", "0"},
|
|
||||||
{"marginheight", "0"},
|
|
||||||
{"leftmargin", "0"},
|
|
||||||
{"marginwidth", "0"},
|
|
||||||
{"rightmargin", "0"}],
|
|
||||||
[?XAE("table",
|
[?XAE("table",
|
||||||
[{"cellpadding", "0"},
|
[{"id", "top"}],
|
||||||
{"cellspacing", "0"},
|
|
||||||
{"border", "0"},
|
|
||||||
{"bgcolor", "#fe8a00"},
|
|
||||||
{"width", "100%"}],
|
|
||||||
[?XE("tr",
|
[?XE("tr",
|
||||||
[?XAE("td", [{"height", "2"}],
|
|
||||||
[?XA("img", [{"src", "/admin/1x1tr.gif"},
|
|
||||||
{"width", "1"},
|
|
||||||
{"height", "2"},
|
|
||||||
{"alt", ""},
|
|
||||||
{"border", "0"}])]),
|
|
||||||
?XAE("td", [{"height", "2"}],
|
|
||||||
[?XA("img", [{"src", "/admin/1x1tr.gif"},
|
|
||||||
{"width", "1"},
|
|
||||||
{"height", "2"},
|
|
||||||
{"alt", ""},
|
|
||||||
{"border", "0"}])])]),
|
|
||||||
?XE("tr",
|
|
||||||
[?XE("td",
|
[?XE("td",
|
||||||
[?XA("img", [{"src", "/admin/logo.png"},
|
[?XA("img", [{"src", "/admin/logo.png"},
|
||||||
{"width", "343"},
|
{"width", "343"},
|
||||||
@ -95,11 +73,7 @@ make_xhtml(Els, Lang) ->
|
|||||||
{"border", "0"}])])])
|
{"border", "0"}])])])
|
||||||
]),
|
]),
|
||||||
?XAE("table",
|
?XAE("table",
|
||||||
[{"cellpadding", "0"},
|
[{"id", "middle"}],
|
||||||
{"cellspacing", "0"},
|
|
||||||
{"border", "0"},
|
|
||||||
{"width", "100%"},
|
|
||||||
{"height", "100%"}],
|
|
||||||
[?XE("tr",
|
[?XE("tr",
|
||||||
[?XAE("td",
|
[?XAE("td",
|
||||||
[{"width", "1"},
|
[{"width", "1"},
|
||||||
@ -123,22 +97,65 @@ make_xhtml(Els, Lang) ->
|
|||||||
{"width", "100%"},
|
{"width", "100%"},
|
||||||
{"bgcolor", "#ffffff"},
|
{"bgcolor", "#ffffff"},
|
||||||
{"valign", "top"}],
|
{"valign", "top"}],
|
||||||
[?XAE("span", [{"id", "content"}], Els)])])
|
[?XAE("div", [{"id", "content"}], Els)])])
|
||||||
]),
|
]),
|
||||||
?XAE("table",
|
?XAE("table",
|
||||||
[{"cellpadding", "0"},
|
[{"id", "bottom"}],
|
||||||
{"cellspacing", "0"},
|
|
||||||
{"border", "0"},
|
|
||||||
{"width", "100%"}],
|
|
||||||
[?XE("tr",
|
[?XE("tr",
|
||||||
[?XA("td",
|
[?XCT("td",
|
||||||
[{"height", "1"},
|
"ejabberd (c) 2002-2004 Alexey Shchepin")
|
||||||
{"bgcolor", "#d47911"}])
|
|
||||||
])
|
])
|
||||||
])]}
|
])])
|
||||||
]}}.
|
]}}.
|
||||||
|
|
||||||
css() -> "
|
css() -> "
|
||||||
|
body {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#top {
|
||||||
|
border: none;
|
||||||
|
border-spacing: 0;
|
||||||
|
background-color: #fe8a00;
|
||||||
|
width: 100%;
|
||||||
|
padding-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#top td {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#top td img {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#middle {
|
||||||
|
border: none;
|
||||||
|
border-spacing: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
empty-cells: show;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#middle td {
|
||||||
|
padding: 0;
|
||||||
|
//background-color: #fe8a00;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#bottom {
|
||||||
|
border: none;
|
||||||
|
border-spacing: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#bottom td {
|
||||||
|
padding: 0;
|
||||||
|
background-color: #fe8a00;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
/*td{
|
/*td{
|
||||||
font-size: 3pt;
|
font-size: 3pt;
|
||||||
}
|
}
|
||||||
@ -354,21 +371,21 @@ h3{
|
|||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
*#content a:link {
|
#content a:link {
|
||||||
color: #444466;
|
color: #444466;
|
||||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-decoration: underlined;
|
text-decoration: underlined;
|
||||||
}
|
}
|
||||||
*#content a:visited {
|
#content a:visited {
|
||||||
color: #444466;
|
color: #444466;
|
||||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-decoration: underlined;
|
text-decoration: underlined;
|
||||||
}
|
}
|
||||||
*#content a:hover {
|
#content a:hover {
|
||||||
color: #222266;
|
color: #222266;
|
||||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
@ -377,17 +394,20 @@ h3{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*#content li{
|
#content li {
|
||||||
list-style-type: dot;
|
list-style-type: dot;
|
||||||
font-size: 7pt;
|
font-size: 7pt;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
*#content li.big{
|
#content li.big {
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div#content {
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
".
|
".
|
||||||
|
|
||||||
@ -516,6 +536,7 @@ process_admin(#request{method = Method,
|
|||||||
error -> [?CT("bad format"), ?P];
|
error -> [?CT("bad format"), ?P];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
|
[?XE("p", [?ACT("../acls-raw/", "raw")])] ++
|
||||||
[?XAE("form", [{"method", "post"}],
|
[?XAE("form", [{"method", "post"}],
|
||||||
[acls_to_xhtml(ACLs),
|
[acls_to_xhtml(ACLs),
|
||||||
?BR,
|
?BR,
|
||||||
@ -620,6 +641,7 @@ process_admin(#request{method = Method,
|
|||||||
error -> [?C("bad format"), ?P];
|
error -> [?C("bad format"), ?P];
|
||||||
nothing -> []
|
nothing -> []
|
||||||
end ++
|
end ++
|
||||||
|
[?XE("p", [?ACT("../access-raw/", "raw")])] ++
|
||||||
[?XAE("form", [{"method", "post"}],
|
[?XAE("form", [{"method", "post"}],
|
||||||
[access_rules_to_xhtml(AccessRules, Lang),
|
[access_rules_to_xhtml(AccessRules, Lang),
|
||||||
?BR,
|
?BR,
|
||||||
@ -654,7 +676,7 @@ process_admin(#request{method = Method,
|
|||||||
Rs1
|
Rs1
|
||||||
end,
|
end,
|
||||||
make_xhtml([?XC("h1",
|
make_xhtml([?XC("h1",
|
||||||
"ejabberd access rule '" ++ SName ++ "' configuration")] ++
|
"'" ++ SName ++ "' access rule configuration")] ++
|
||||||
case Res of
|
case Res of
|
||||||
ok -> [?C("submited"), ?P];
|
ok -> [?C("submited"), ?P];
|
||||||
error -> [?C("bad format"), ?P];
|
error -> [?C("bad format"), ?P];
|
||||||
@ -688,6 +710,13 @@ process_admin(#request{user = User,
|
|||||||
Res = get_stats(Lang),
|
Res = get_stats(Lang),
|
||||||
make_xhtml([?XC("h1", "ejabberd stats")] ++ Res, Lang);
|
make_xhtml([?XC("h1", "ejabberd stats")] ++ Res, Lang);
|
||||||
|
|
||||||
|
process_admin(#request{user = User,
|
||||||
|
path = ["user", U],
|
||||||
|
q = Query,
|
||||||
|
lang = Lang} = Request) ->
|
||||||
|
Res = user_info(U, Query, Lang),
|
||||||
|
make_xhtml(Res, Lang);
|
||||||
|
|
||||||
process_admin(#request{lang = Lang}) ->
|
process_admin(#request{lang = Lang}) ->
|
||||||
setelement(1, make_xhtml([?XC("h1", "Not found")], Lang), 404).
|
setelement(1, make_xhtml([?XC("h1", "Not found")], Lang), 404).
|
||||||
|
|
||||||
@ -723,7 +752,7 @@ acl_spec_to_text({server, S}) ->
|
|||||||
{server, S};
|
{server, S};
|
||||||
|
|
||||||
acl_spec_to_text({user, U, S}) ->
|
acl_spec_to_text({user, U, S}) ->
|
||||||
{user, U ++ "@" ++ S};
|
{user_server, U ++ "@" ++ S};
|
||||||
|
|
||||||
acl_spec_to_text(Spec) ->
|
acl_spec_to_text(Spec) ->
|
||||||
{raw, term_to_string(Spec)}.
|
{raw, term_to_string(Spec)}.
|
||||||
@ -983,3 +1012,46 @@ get_stats(Lang) ->
|
|||||||
?XC("td", integer_to_list(S2SServers))])
|
?XC("td", integer_to_list(S2SServers))])
|
||||||
])
|
])
|
||||||
])].
|
])].
|
||||||
|
|
||||||
|
|
||||||
|
user_info(User, Query, Lang) ->
|
||||||
|
Res = user_parse_query(User, Query),
|
||||||
|
Resources = ejabberd_sm:get_user_resources(User),
|
||||||
|
FResources =
|
||||||
|
case Resources of
|
||||||
|
[] ->
|
||||||
|
[?CT("None")];
|
||||||
|
_ ->
|
||||||
|
[?XE("ul",
|
||||||
|
lists:map(fun(R) ->
|
||||||
|
?LI([?C(R)])
|
||||||
|
end, lists:sort(Resources)))]
|
||||||
|
end,
|
||||||
|
Password = ejabberd_auth:get_password_s(User),
|
||||||
|
FPassword = [?INPUT("text", "password", Password), ?C(" "),
|
||||||
|
?INPUTT("submit", "chpassword", "Change Password")],
|
||||||
|
[?XC("h1", "User: " ++ User)] ++
|
||||||
|
case Res of
|
||||||
|
ok -> [?C("submited"), ?P];
|
||||||
|
error -> [?C("bad format"), ?P];
|
||||||
|
nothing -> []
|
||||||
|
end ++
|
||||||
|
[?XAE("form", [{"method", "post"}],
|
||||||
|
[?XCT("h3", "Connected Resources:")] ++ FResources ++
|
||||||
|
[?XCT("h3", "Password:")] ++ FPassword)].
|
||||||
|
|
||||||
|
|
||||||
|
user_parse_query(User, Query) ->
|
||||||
|
case lists:keysearch("chpassword", 1, Query) of
|
||||||
|
{value, _} ->
|
||||||
|
case lists:keysearch("password", 1, Query) of
|
||||||
|
{value, {_, Password}} ->
|
||||||
|
ejabberd_auth:set_password(User, Password),
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
error
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
nothing
|
||||||
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user