|
@@ -55,7 +55,18 @@ var Map_stype = map[string]bool{
|
|
|
"advancedProject": true,
|
|
|
}
|
|
|
|
|
|
+var seoAgentReg = regexp.MustCompile("Baiduspider|360Spider|bingbot|Googlebot")
|
|
|
+
|
|
|
func (s *Short) Article(stype, id string) error {
|
|
|
+ userId, _ := s.GetSession("userId").(string)
|
|
|
+ if stype == "article" && userId == "" && seoAgentReg.MatchString(s.UserAgent()) {
|
|
|
+ sids := encrypt.CommonDecodeArticle(stype, id)
|
|
|
+ return s.NologinCommon("", "nologin", encrypt.CommonEncodeArticle("nologin", sids[0]), sids[0])
|
|
|
+ }
|
|
|
+ return s.LoginCommon(userId, stype, id)
|
|
|
+}
|
|
|
+
|
|
|
+func (s *Short) LoginCommon(userId, stype, id string) error {
|
|
|
client := s.Header("User-Agent")
|
|
|
bm := mobileReg.MatchString(client)
|
|
|
//电脑端 剑鱼快照页面访问
|
|
@@ -96,12 +107,11 @@ func (s *Short) Article(stype, id string) error {
|
|
|
}
|
|
|
aboutUrl += "&from=" + from_userid
|
|
|
}
|
|
|
- userId, _ := s.GetSession("userId").(string)
|
|
|
if !Map_stype[stype] {
|
|
|
s.Redirect("/not/nottype", 302)
|
|
|
return nil
|
|
|
} else if stype == "content" || stype == "bdcontent" || stype == "advancedProject" {
|
|
|
- if s.Session().Get("userId") == nil {
|
|
|
+ if userId == "" {
|
|
|
if s.GetString("state") == "wx" {
|
|
|
//微信跳回来的
|
|
|
if code := s.GetString("code"); code != "" {
|
|
@@ -119,7 +129,7 @@ func (s *Short) Article(stype, id string) error {
|
|
|
if disWord != "" {
|
|
|
from_userid = disWordNil(disWord, userId)
|
|
|
}
|
|
|
- if s.Session().Get("userId") == nil { //} && !regclient.MatchString(client) { //没有用户session //搜索引擎让过
|
|
|
+ if userId == "" { //} && !regclient.MatchString(client) { //没有用户session //搜索引擎让过
|
|
|
s.Session().Set("referer", s.Request.RequestURI)
|
|
|
if bm { //是否是移动端访问
|
|
|
s.Redirect(aboutUrl, 302)
|
|
@@ -283,7 +293,7 @@ func (s *Short) Article(stype, id string) error {
|
|
|
return s.Redirect(aboutUrl, 302)
|
|
|
}
|
|
|
//之前sessionkeep.go中没有放userId,造成关注有问题
|
|
|
- if s.GetSession("userId") == nil {
|
|
|
+ if userId == "" {
|
|
|
FindUserAndCreateSess(ssOpenid.(string), s.Session(), "wx", false, true)
|
|
|
}
|
|
|
}
|
|
@@ -977,13 +987,14 @@ func (s *Short) NologinArticle(stype, id string) error {
|
|
|
s.Redirect("/notin/page", 302)
|
|
|
return nil
|
|
|
}
|
|
|
- sid := sids[0]
|
|
|
-
|
|
|
- tg := &Tags{}
|
|
|
-
|
|
|
if userId != "" { //已登录用户直接跳转至正常三级页
|
|
|
- return s.Redirect(fmt.Sprintf("/article/content/%s.html", encrypt.CommonEncodeArticle("content", sid)))
|
|
|
+ return s.LoginCommon(userId, "article", encrypt.CommonEncodeArticle("content", sids[0]))
|
|
|
}
|
|
|
+ return s.NologinCommon(userId, stype, id, sids[0])
|
|
|
+}
|
|
|
+
|
|
|
+func (s *Short) NologinCommon(userId, stype, id, sid string) error {
|
|
|
+ tg := &Tags{}
|
|
|
catchKey := fmt.Sprintf("jypcdetail_nologin_%s_%s", stype, sid)
|
|
|
if res := redis.Get("newother", catchKey); res == nil || res == "" {
|
|
|
industry := s.GetString("industry")
|