diff --git a/src/contexts/aaa/aaa.go b/src/contexts/aaa/aaa.go index ac4785cf..d7121e8e 100644 --- a/src/contexts/aaa/aaa.go +++ b/src/contexts/aaa/aaa.go @@ -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)}, diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index 9936b73b..e205a2eb 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -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")) diff --git a/src/examples/wiki/wiki.go b/src/examples/wiki/wiki.go index ed2f5780..7cef006b 100644 --- a/src/examples/wiki/wiki.go +++ b/src/examples/wiki/wiki.go @@ -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{})