Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f7dfd4ec77 | |||
| 2276aa12ef | |||
| 6505594fd0 |
+1
-1
@@ -376,7 +376,7 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
|
||||
//访问拦截true继续false暂停
|
||||
connectListenerLen := len(that.connectListener)
|
||||
|
||||
for i := connectListenerLen - 1; i >= 0; i-- {
|
||||
for i := 0; i < connectListenerLen; i++ {
|
||||
|
||||
if that.connectListener[i](&context) {
|
||||
|
||||
|
||||
+3
-1
@@ -1081,7 +1081,9 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
parentID = userData.GetCeilInt(table + "_id")
|
||||
data["OR"] = Map{table + ".id": parentID, table + ".parent_id": nil}
|
||||
} else {
|
||||
data[table+".parent_id"] = reqValue
|
||||
|
||||
data["OR"] = Map{table + ".parent_id": reqValue, table + ".id": reqValue}
|
||||
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
+11
@@ -5,6 +5,7 @@ import (
|
||||
. "code.hoteas.com/golang/hotime/db"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -74,6 +75,16 @@ func (that *Context) View() {
|
||||
if that.Session("user_id").Data != nil {
|
||||
that.Log["user_id"] = that.Session("user_id").ToCeilInt()
|
||||
}
|
||||
ipStr := Substr(that.Req.RemoteAddr, 0, strings.Index(that.Req.RemoteAddr, ":"))
|
||||
//负载均衡优化
|
||||
if ipStr == "127.0.0.1" {
|
||||
if that.Req.Header.Get("X-Forwarded-For") != "" {
|
||||
ipStr = that.Req.Header.Get("X-Forwarded-For")
|
||||
} else if that.Req.Header.Get("X-Real-IP") != "" {
|
||||
ipStr = that.Req.Header.Get("X-Real-IP")
|
||||
}
|
||||
}
|
||||
that.Log["ip"] = ipStr
|
||||
that.Db.Insert("logs", that.Log)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user