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