mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt some
This commit is contained in:
parent
e167f23c70
commit
054c3ebca7
@ -1,16 +1,15 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/aaa"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -91,9 +90,17 @@ func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path
|
||||
func RenderType(w http.ResponseWriter, name, mime string) {
|
||||
if mime != "" {
|
||||
w.Header().Set(ContentType, mime)
|
||||
} else if strings.HasSuffix(name, ".css") {
|
||||
return
|
||||
}
|
||||
|
||||
switch kit.Ext(name) {
|
||||
case "css":
|
||||
w.Header().Set(ContentType, "text/css; charset=utf-8")
|
||||
} else {
|
||||
case "pdf":
|
||||
w.Header().Set(ContentType, "application/pdf")
|
||||
|
||||
default:
|
||||
break
|
||||
w.Header().Set(ContentType, ContentHTML)
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +171,12 @@ func _serve_login(msg *ice.Message, cmds []string, w http.ResponseWriter, r *htt
|
||||
if ls := strings.Split(r.URL.Path, "/"); msg.Conf(SERVE, kit.Keym(aaa.BLACK, ls[1])) == "true" {
|
||||
return cmds, false // 黑名单
|
||||
} else if msg.Conf(SERVE, kit.Keym(aaa.WHITE, ls[1])) == "true" {
|
||||
if msg.Option(ice.MSG_USERNAME) == "" && msg.Option(SHARE) != "" {
|
||||
share := msg.Cmd(SHARE, msg.Option(SHARE))
|
||||
msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME))
|
||||
msg.Option(ice.MSG_USERROLE, share.Append(aaa.USERROLE))
|
||||
msg.Debug("login ")
|
||||
}
|
||||
return cmds, true // 白名单
|
||||
}
|
||||
|
||||
|
@ -54,27 +54,31 @@ func _action_right(m *ice.Message, river string, storm string) (ok bool) {
|
||||
}
|
||||
return ok
|
||||
}
|
||||
func _action_share(m *ice.Message, cmd string, arg ...string) {
|
||||
func _action_share(m *ice.Message, arg ...string) {
|
||||
switch msg := m.Cmd(web.SHARE, arg[1]); msg.Append(kit.MDB_TYPE) {
|
||||
case web.FIELD:
|
||||
if cmd := kit.Keys(msg.Append(web.RIVER), msg.Append(web.STORM)); len(arg) == 2 {
|
||||
m.Push("index", cmd)
|
||||
m.Push("title", msg.Append(kit.MDB_NAME))
|
||||
m.Push("args", msg.Append(kit.MDB_TEXT))
|
||||
} else {
|
||||
if m.Warn(kit.Time() > kit.Time(msg.Append(kit.MDB_TIME)), ice.ErrExpire) {
|
||||
return // 分享超时
|
||||
}
|
||||
m.Log_AUTH(
|
||||
aaa.USERROLE, m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE)),
|
||||
aaa.USERNAME, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)),
|
||||
)
|
||||
if m.Warn(!m.Right(arg[3:]), ice.ErrNotRight) {
|
||||
return // 没有授权
|
||||
}
|
||||
|
||||
m.Cmdy(cmd, arg[3:])
|
||||
break
|
||||
}
|
||||
|
||||
if m.Warn(kit.Time() > kit.Time(msg.Append(kit.MDB_TIME)), ice.ErrExpire) {
|
||||
break // 分享超时
|
||||
}
|
||||
m.Log_AUTH(
|
||||
aaa.USERROLE, m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE)),
|
||||
aaa.USERNAME, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)),
|
||||
)
|
||||
if m.Warn(!m.Right(arg[2:]), ice.ErrNotRight) {
|
||||
break // 没有授权
|
||||
}
|
||||
|
||||
if m.Option(ice.MSG_UPLOAD) != "" {
|
||||
_action_upload(m) // 上传文件
|
||||
}
|
||||
m.Cmdy(arg[2:])
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +148,7 @@ func init() {
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if arg[0] == "_share" {
|
||||
_action_share(m, cmd, arg...)
|
||||
_action_share(m, arg...)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user