Prechádzať zdrojové kódy

Merge branch 'master' into feature/v4.8.29

lianbingjie 2 rokov pred
rodič
commit
c573724fd9
3 zmenil súbory, kde vykonal 26 pridanie a 12 odobranie
  1. 22 9
      src/jfw/front/shorturl.go
  2. 1 1
      src/jfw/jyutil/sessionkeep.go
  3. 3 2
      src/main.go

+ 22 - 9
src/jfw/front/shorturl.go

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

+ 1 - 1
src/jfw/jyutil/sessionkeep.go

@@ -95,7 +95,7 @@ func (sk *SessionKeep) Do() bool {
 			}
 			}
 		} else {
 		} else {
 			if strings.HasPrefix(rqu, "/article/") {
 			if strings.HasPrefix(rqu, "/article/") {
-				if strings.HasPrefix(rqu, "/article/mailprivate") || strings.HasPrefix(rqu, "/article/bdprivate") || strings.HasPrefix(rqu, "/article/bdcontent") || reg.MatchString(rhdua) || strings.HasPrefix(rqu, "/article/indexcontent") {
+				if strings.HasPrefix(rqu, "/article/content") || strings.HasPrefix(rqu, "/article/mailprivate") || strings.HasPrefix(rqu, "/article/bdprivate") || strings.HasPrefix(rqu, "/article/bdcontent") || reg.MatchString(rhdua) || strings.HasPrefix(rqu, "/article/indexcontent") {
 					return true
 					return true
 				} else { //只处理pc
 				} else { //只处理pc
 					sk.SetSession["referer"] = sk.R.RequestURI
 					sk.SetSession["referer"] = sk.R.RequestURI

+ 3 - 2
src/main.go

@@ -1,13 +1,14 @@
 package main
 package main
 
 
 import (
 import (
-	"app.yhyue.com/moapp/jybase/fsw"
-	"app.yhyue.com/moapp/jylog"
 	_ "jy/src/jfw/active"
 	_ "jy/src/jfw/active"
 	"jy/src/jfw/config"
 	"jy/src/jfw/config"
 	. "jy/src/jfw/config"
 	. "jy/src/jfw/config"
 	_ "jy/src/jfw/site"
 	_ "jy/src/jfw/site"
 
 
+	"app.yhyue.com/moapp/jybase/fsw"
+	"app.yhyue.com/moapp/jylog"
+
 	// _ "jy/src/jfw/modules/app/src/jfw/course"  线下课程 dev3.5.2 21年2.24 下线
 	// _ "jy/src/jfw/modules/app/src/jfw/course"  线下课程 dev3.5.2 21年2.24 下线
 	_ "jy/src/jfw/filter"
 	_ "jy/src/jfw/filter"
 	"jy/src/jfw/front"
 	"jy/src/jfw/front"