|
@@ -48,6 +48,7 @@ type Short struct {
|
|
|
nologinArticle xweb.Mapper `xweb:"/nologin/(\\w+)/(.*).html"` //([pm]) 无需登录
|
|
|
whiteList xweb.Mapper `xweb:"/initialize/whiteList"` //白名单初始化
|
|
|
clearCache xweb.Mapper `xweb:"/front/free/clearCache"` //清楚缓存
|
|
|
+ notFindPage xweb.Mapper `xweb:"/front/notFind"` //清楚缓存
|
|
|
}
|
|
|
|
|
|
var (
|
|
@@ -100,6 +101,10 @@ var (
|
|
|
cacheLock = sync.Mutex{}
|
|
|
)
|
|
|
|
|
|
+func (s *Short) NotFindPage() error {
|
|
|
+ return s.Render("/pc/tags/404.html")
|
|
|
+}
|
|
|
+
|
|
|
func (s *Short) ClearCache() {
|
|
|
defer util.Catch()
|
|
|
cacheLock.Lock()
|
|
@@ -179,16 +184,28 @@ func (s *Short) Article(stype, id string) error {
|
|
|
}
|
|
|
//PC端未登录用户程序走此逻辑 WX端走原来逻辑
|
|
|
if !bm && (stype == "content" || stype == "indexcontent" || stype == "mailprivate") && userId == "" {
|
|
|
- //if seoAgentReg.MatchString(s.UserAgent()) {
|
|
|
sids := encrypt.CommonDecodeArticle(stype, id)
|
|
|
- return s.NologinCommon("", stype, id, sids[0])
|
|
|
- //} else {
|
|
|
- // return s.Redirect("/notin/page")
|
|
|
- //}
|
|
|
+ if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
|
|
|
+ return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
|
|
|
+ }
|
|
|
+ return s.NologinCommon("", stype, id, sids[0], bm)
|
|
|
}
|
|
|
return s.LoginCommon(sess, stype, id, bm)
|
|
|
}
|
|
|
|
|
|
+const (
|
|
|
+ DecodeErr = iota + 1
|
|
|
+ QueryErr
|
|
|
+ UndefinedType
|
|
|
+)
|
|
|
+
|
|
|
+func getErrPageUrl(isMobile bool, t int) string {
|
|
|
+ if isMobile {
|
|
|
+ return fmt.Sprintf("/jyapp/notFind?t=%d", t)
|
|
|
+ }
|
|
|
+ return fmt.Sprintf("/front/notFind?t=%d", t)
|
|
|
+}
|
|
|
+
|
|
|
func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bool) error {
|
|
|
userId, _ := sess["userId"].(string)
|
|
|
log.Println(stype, "----stype:---", id, "---userId---:", userId, "----", bm)
|
|
@@ -207,10 +224,15 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
}
|
|
|
//P406登录用户标讯详情页改版
|
|
|
if userId != "" {
|
|
|
- s.T["title"], s.T["keywords"], s.T["description"] = GetTDK(stype, encrypt.CommonDecodeArticle(stype, id)[0])
|
|
|
+ sids := encrypt.CommonDecodeArticle(stype, id)
|
|
|
+ if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
|
|
|
+ s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ s.T["title"], s.T["keywords"], s.T["description"] = GetTDK(stype, sids[0])
|
|
|
return s.Render("/pc/detail/biddetail_login.html", &s.T)
|
|
|
}
|
|
|
- } else if userId != "" { //&& strings.Contains(s.Request.RequestURI, "article")
|
|
|
+ } else if userId != "" { //移动端登录
|
|
|
//mobileHtmlKey := "jy_mobile_index_wx"
|
|
|
var loginPageInfo = func() (body []byte) {
|
|
|
// 获取页面内容
|
|
@@ -278,19 +300,22 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
aboutUrl += "&from=" + from_userid
|
|
|
}
|
|
|
if !Map_stype[stype] {
|
|
|
- s.Redirect("/not/nottype", 302)
|
|
|
- return nil
|
|
|
+ return s.Redirect(getErrPageUrl(bm, UndefinedType), 302)
|
|
|
} else if stype == "content" || stype == "bdcontent" || stype == "advancedProject" {
|
|
|
if userId == "" { //} && !regclient.MatchString(client) { //没有用户session //搜索引擎让过
|
|
|
s.Session().Set("referer", s.Request.RequestURI)
|
|
|
if bm { //是否是移动端访问
|
|
|
s.Redirect(aboutUrl, 302)
|
|
|
+ return nil
|
|
|
} else {
|
|
|
if stype == "bdcontent" {
|
|
|
var retMap = make(map[string]interface{})
|
|
|
stype = "content"
|
|
|
- _id := encrypt.CommonDecodeArticle(stype, id)[0]
|
|
|
- _, _, _, obj := pcVRT(_id, "", stype, true, true)
|
|
|
+ sids := encrypt.CommonDecodeArticle(stype, id)
|
|
|
+ if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
|
|
|
+ return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
|
|
|
+ }
|
|
|
+ _, _, _, obj := pcVRT(sids[0], "", stype, true, true)
|
|
|
if obj != nil && len(obj) > 0 {
|
|
|
retMap["_id"] = url.QueryEscape(id)
|
|
|
retMap["title"], _ = obj["title"].(string)
|
|
@@ -306,7 +331,7 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
s.T["obj"] = retMap
|
|
|
s.Render("/pc/biddetail_bd.html", &s.T)
|
|
|
} else {
|
|
|
- s.Redirect("/notin/page", 302)
|
|
|
+ s.Redirect(getErrPageUrl(bm, UndefinedType), 302)
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
@@ -321,8 +346,7 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
sid := encrypt.SE3.DecodeString(id)
|
|
|
log.Println("----sid:---", sid)
|
|
|
if len(sid) == 0 || (len(sid) > 0 && sid == "") { //未登录用户没有权限访问---userId == "" || 未登录可以访问来自陈 11.29
|
|
|
- s.Redirect("/notin/page", 302)
|
|
|
- return nil
|
|
|
+ return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
|
|
|
}
|
|
|
catchKey := fmt.Sprintf("jypcdetail_%s_%s_%s", userId, stype, sid)
|
|
|
if res := redis.Get(redisLimitation, catchKey); res == nil || res == "" {
|
|
@@ -390,6 +414,8 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
content, _ := s.Render4Cache("/pc/biddetail_rec.html", &s.T)
|
|
|
redis.Put(redisLimitation, catchKey, string(content), 60*20)
|
|
|
return s.SetBody(content)
|
|
|
+ } else {
|
|
|
+ return s.Redirect(getErrPageUrl(bm, QueryErr), 302)
|
|
|
}
|
|
|
} else {
|
|
|
return s.SetBody([]byte(res.(string)))
|
|
@@ -462,8 +488,7 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
sid_openid := encrypt.CommonDecodeArticle(stype, id)
|
|
|
switch len(sid_openid) {
|
|
|
case 0:
|
|
|
- s.Redirect(aboutUrl, 302)
|
|
|
- return nil
|
|
|
+ return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
|
|
|
default:
|
|
|
shareopenid, sid = SwiDef(sid_openid)
|
|
|
}
|
|
@@ -587,15 +612,15 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
s.T["rewardText"], s.T["advertText"] = getRewardText()
|
|
|
content, _ := s.Render4Cache("/weixin/wxinfocontent_rec.html", &s.T)
|
|
|
return s.SetBody(content)
|
|
|
- }
|
|
|
- if surl != "" {
|
|
|
+ } else if surl == "" {
|
|
|
+ return s.Redirect(getErrPageUrl(bm, QueryErr), 302)
|
|
|
+ } else {
|
|
|
return s.Redirect(surl)
|
|
|
}
|
|
|
} else {
|
|
|
sids := encrypt.CommonDecodeArticle(stype, id)
|
|
|
if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
|
|
|
- s.Redirect("/notin/page", 302)
|
|
|
- return nil
|
|
|
+ return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
|
|
|
}
|
|
|
sid := sids[0]
|
|
|
//免费用户浏览三级页判断留资与浏览次数
|
|
@@ -751,6 +776,8 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
|
|
|
redis.Put(redisLimitation, catchKey, string(content), redisTimeOut)
|
|
|
return s.SetBody(content)
|
|
|
//return s.Render("/pc/biddetail_rec.html", &s.T)
|
|
|
+ } else {
|
|
|
+ return s.Redirect(getErrPageUrl(bm, QueryErr), 302)
|
|
|
}
|
|
|
} else {
|
|
|
return s.SetBody([]byte(res.(string)))
|
|
@@ -1322,24 +1349,22 @@ func (s *Short) NologinArticle(stype, id string) error {
|
|
|
sess := s.Session().GetMultiple()
|
|
|
userId := util.ObjToString(sess["userId"])
|
|
|
sids := encrypt.CommonDecodeArticle(stype, id)
|
|
|
+ bm := mobileReg.MatchString(s.Header("User-Agent"))
|
|
|
if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
|
|
|
- s.Redirect("/notin/page", 302)
|
|
|
- return nil
|
|
|
+ return s.Redirect(getErrPageUrl(bm, DecodeErr), 302)
|
|
|
}
|
|
|
if detailNeedMosaic == nil {
|
|
|
detailNeedMosaic, _ = config.Sysconfig["detailNeedMosaic"].(map[string]interface{})
|
|
|
}
|
|
|
- //urlStr := strings.ReplaceAll(s.Request.URL.String(), "nologin", "article")
|
|
|
- //return s.Redirect(urlStr, 301)
|
|
|
|
|
|
if userId != "" { //已登录用户直接跳转至正常三级页
|
|
|
- return s.LoginCommon(sess, stype, id, mobileReg.MatchString(s.Header("User-Agent"))) //是否是移动端
|
|
|
+ return s.LoginCommon(sess, stype, id, bm) //是否是移动端
|
|
|
}
|
|
|
|
|
|
- return s.NologinCommon(userId, stype, id, sids[0])
|
|
|
+ return s.NologinCommon(userId, stype, id, sids[0], bm)
|
|
|
}
|
|
|
|
|
|
-func (s *Short) NologinCommon(userId, stype, id, sid string) error {
|
|
|
+func (s *Short) NologinCommon(userId, stype, id, sid string, isMobile bool) error {
|
|
|
tg := &Tags{}
|
|
|
var ipTrue bool
|
|
|
ips := strings.Split(util.GetIp(s.Request), ",")
|
|
@@ -1416,6 +1441,8 @@ func (s *Short) NologinCommon(userId, stype, id, sid string) error {
|
|
|
content, _ := s.Render4Cache("/pc/tags/detail.html", &s.T)
|
|
|
redis.Put(redisLimitation, catchKey, string(content), 60*2)
|
|
|
return s.SetBody(content)
|
|
|
+ } else {
|
|
|
+ return s.Redirect(getErrPageUrl(isMobile, QueryErr), 302)
|
|
|
}
|
|
|
} else {
|
|
|
return s.SetBody([]byte(res.(string)))
|