1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

add access

This commit is contained in:
shylinux 2019-06-07 13:20:22 +08:00
parent b133aa5ac4
commit 5c858eb440
3 changed files with 58 additions and 46 deletions

View File

@ -539,6 +539,15 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心",
}
switch arg[0] {
case "access": // 查看用户
h := m.Cmdx("aaa.auth", "access", kit.Hashs(m.Option("remote_ip"), m.Option("username")))
m.Cmd("aaa.auth", h, "data",
"remote_ip", m.Option("remote_ip"),
"username", m.Option("username"),
)
m.Echo(h)
return
case "user": // 查看用户
m.Log("fuck", "what %v", arg)
m.Cmdy("aaa.auth", sid, "ship", "username")
@ -766,8 +775,8 @@ var Index = &ctx.Context{Name: "aaa", Help: "认证中心",
// 生成证书
template := x509.Certificate{
SerialNumber: big.NewInt(1),
IsCA: true,
SerialNumber: big.NewInt(1),
IsCA: true,
BasicConstraintsValid: true,
KeyUsage: x509.KeyUsageCertSign,
Subject: pkix.Name{CommonName: kit.Format(common)},

View File

@ -92,6 +92,9 @@ func (web *WEB) Login(msg *ctx.Message, w http.ResponseWriter, r *http.Request)
// if msg.Confs("skip_login", msg.Option("path")) {
// return true
// }
defer func() {
msg.Option("access", msg.Cmdx("aaa.sess", "access"))
}()
if msg.Confs("login", "cas") {
if !cas.IsAuthenticated(r) {
r.URL, _ = r.URL.Parse(r.Header.Get("index_url"))
@ -656,54 +659,54 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
m.Put("option", "data", result).Cmdy("mdb.temp", "url", uri+uri_arg, "data", "data", m.Meta["temp"])
case parse == "html":
/*
page, e := goquery.NewDocumentFromReader(res.Body)
m.Assert(e)
/*
page, e := goquery.NewDocumentFromReader(res.Body)
m.Assert(e)
page.Find(kit.Select("html", m.Option("parse_chain"))).Each(func(n int, s *goquery.Selection) {
if m.Options("parse_select") {
for i := 0; i < len(m.Meta["parse_select"])-2; i += 3 {
item := s.Find(m.Meta["parse_select"][i+1])
if m.Meta["parse_select"][i+1] == "" {
item = s
page.Find(kit.Select("html", m.Option("parse_chain"))).Each(func(n int, s *goquery.Selection) {
if m.Options("parse_select") {
for i := 0; i < len(m.Meta["parse_select"])-2; i += 3 {
item := s.Find(m.Meta["parse_select"][i+1])
if m.Meta["parse_select"][i+1] == "" {
item = s
}
if v, ok := item.Attr(m.Meta["parse_select"][i+2]); ok {
m.Add("append", m.Meta["parse_select"][i], v)
m.Log("info", "item attr %v", v)
} else {
m.Add("append", m.Meta["parse_select"][i], strings.Replace(item.Text(), "\n", "", -1))
m.Log("info", "item text %v", item.Text())
}
}
if v, ok := item.Attr(m.Meta["parse_select"][i+2]); ok {
m.Add("append", m.Meta["parse_select"][i], v)
m.Log("info", "item attr %v", v)
} else {
m.Add("append", m.Meta["parse_select"][i], strings.Replace(item.Text(), "\n", "", -1))
m.Log("info", "item text %v", item.Text())
return
}
s.Find("a").Each(func(n int, s *goquery.Selection) {
if attr, ok := s.Attr("href"); ok {
s.SetAttr("href", proxy(m, attr))
}
}
return
}
})
s.Find("img").Each(func(n int, s *goquery.Selection) {
if attr, ok := s.Attr("src"); ok {
s.SetAttr("src", proxy(m, attr))
}
if attr, ok := s.Attr("r-lazyload"); ok {
s.SetAttr("src", proxy(m, attr))
}
})
s.Find("script").Each(func(n int, s *goquery.Selection) {
if attr, ok := s.Attr("src"); ok {
s.SetAttr("src", proxy(m, attr))
}
})
s.Find("a").Each(func(n int, s *goquery.Selection) {
if attr, ok := s.Attr("href"); ok {
s.SetAttr("href", proxy(m, attr))
}
})
s.Find("img").Each(func(n int, s *goquery.Selection) {
if attr, ok := s.Attr("src"); ok {
s.SetAttr("src", proxy(m, attr))
}
if attr, ok := s.Attr("r-lazyload"); ok {
s.SetAttr("src", proxy(m, attr))
}
})
s.Find("script").Each(func(n int, s *goquery.Selection) {
if attr, ok := s.Attr("src"); ok {
s.SetAttr("src", proxy(m, attr))
if html, e := s.Html(); e == nil {
m.Add("append", "html", html)
}
})
m.Table()
if html, e := s.Html(); e == nil {
m.Add("append", "html", html)
}
})
m.Table()
*/
*/
default:
if m.Options("save") {
f, e := os.Create(m.Option("save"))

View File

@ -73,9 +73,9 @@ var Index = &ctx.Context{Name: "wiki", Help: "文档中心",
which := m.Cmdx("nfs.path", path.Join(m.Confx("wiki_level"), m.Option("wiki_class"), m.Confx("wiki_favor", arg, 0)))
if ls, e := ioutil.ReadFile(which); e == nil {
m.Confi("wiki_visit", []string{which, m.Option("remote_ip")},
m.Confi("wiki_visit", []string{which, m.Option("remote_ip")})+1)
m.Append("visit_count", m.Confi("wiki_visit", []string{which, m.Option("remote_ip")}))
m.Conf("wiki_visit", []string{which, m.Option("access")},
m.Confi("wiki_visit", []string{which, m.Option("access")})+1)
m.Append("visit_count", m.Confi("wiki_visit", []string{which, m.Option("access")}))
m.Append("visit_total", len(m.Confm("wiki_visit", []string{which})))
buffer := bytes.NewBuffer([]byte{})