mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt website
This commit is contained in:
parent
2d03bdbbef
commit
1563fd7ee6
@ -3,6 +3,7 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@ -31,9 +32,6 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
|||||||
for i := 0; i < len(env)-1; i += 2 {
|
for i := 0; i < len(env)-1; i += 2 {
|
||||||
cmd.Env = append(cmd.Env, kit.Format("%s=%s", env[i], env[i+1]))
|
cmd.Env = append(cmd.Env, kit.Format("%s=%s", env[i], env[i+1]))
|
||||||
if env[i] == PATH {
|
if env[i] == PATH {
|
||||||
// if strings.Contains(m.Cmdx(RUNTIME, "host.OSID"), ALPINE) {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
if file := _system_find(m, arg[0], strings.Split(env[i+1], ice.DF)...); file != "" {
|
if file := _system_find(m, arg[0], strings.Split(env[i+1], ice.DF)...); file != "" {
|
||||||
cmd.Path = file
|
cmd.Path = file
|
||||||
break
|
break
|
||||||
@ -42,15 +40,12 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// // 定制目录
|
// // 定制目录
|
||||||
// if buf, err := ioutil.ReadFile(ice.ETC_PATH); err == nil && len(buf) > 0 {
|
if buf, err := ioutil.ReadFile(ice.ETC_PATH); err == nil && len(buf) > 0 {
|
||||||
// for _, p := range strings.Split(string(buf), ice.NL) {
|
if file := _system_find(m, arg[0], strings.Split(string(buf), ice.NL)...); file != "" {
|
||||||
// if _, e := os.Stat(path.Join(p, arg[0])); e == nil {
|
// cmd.Path = file
|
||||||
// cmd.Path = kit.Path(path.Join(p, arg[0]))
|
// break
|
||||||
// m.Debug("what %v", cmd.Path)
|
}
|
||||||
// break
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
m.Debug("cmd: %v", cmd.Path)
|
m.Debug("cmd: %v", cmd.Path)
|
||||||
|
|
||||||
if len(cmd.Env) > 0 {
|
if len(cmd.Env) > 0 {
|
||||||
|
@ -32,7 +32,7 @@ func Render(msg *ice.Message, cmd string, args ...interface{}) {
|
|||||||
RenderCookie(msg, arg[0], arg[1:]...)
|
RenderCookie(msg, arg[0], arg[1:]...)
|
||||||
|
|
||||||
case ice.RENDER_REDIRECT: // url [arg...]
|
case ice.RENDER_REDIRECT: // url [arg...]
|
||||||
http.Redirect(msg.W, msg.R, kit.MergeURL(arg[0], arg[1:]), http.StatusSeeOther)
|
RenderRedirect(msg, arg...)
|
||||||
|
|
||||||
case ice.RENDER_DOWNLOAD: // file [type [name]]
|
case ice.RENDER_DOWNLOAD: // file [type [name]]
|
||||||
if strings.HasPrefix(arg[0], "http") {
|
if strings.HasPrefix(arg[0], "http") {
|
||||||
@ -88,6 +88,9 @@ func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path
|
|||||||
http.SetCookie(msg.W, &http.Cookie{Value: value,
|
http.SetCookie(msg.W, &http.Cookie{Value: value,
|
||||||
Name: kit.Select(CookieName(msg.Option(ice.MSG_USERWEB)), arg, 0), Path: kit.Select(ice.PS, arg, 1), Expires: expire})
|
Name: kit.Select(CookieName(msg.Option(ice.MSG_USERWEB)), arg, 0), Path: kit.Select(ice.PS, arg, 1), Expires: expire})
|
||||||
}
|
}
|
||||||
|
func RenderRedirect(msg *ice.Message, arg ...string) {
|
||||||
|
http.Redirect(msg.W, msg.R, kit.MergeURL(arg[0], arg[1:]), http.StatusMovedPermanently)
|
||||||
|
}
|
||||||
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)
|
||||||
|
@ -184,12 +184,10 @@ func _serve_login(msg *ice.Message, key string, cmds []string, w http.ResponseWr
|
|||||||
|
|
||||||
if msg.Option(ice.MSG_USERNAME) == "" && msg.Option(SHARE) != "" {
|
if msg.Option(ice.MSG_USERNAME) == "" && msg.Option(SHARE) != "" {
|
||||||
switch share := msg.Cmd(SHARE, msg.Option(SHARE)); share.Append(mdb.TYPE) {
|
switch share := msg.Cmd(SHARE, msg.Option(SHARE)); share.Append(mdb.TYPE) {
|
||||||
case LOGIN: // 共享认证
|
case STORM, FIELD: // 共享认证
|
||||||
msg.Option(ice.MSG_USERROLE, share.Append(aaa.USERROLE))
|
|
||||||
msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME))
|
|
||||||
case FIELD: // 共享认证
|
|
||||||
msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME))
|
msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME))
|
||||||
msg.Option(ice.MSG_USERROLE, share.Append(aaa.USERROLE))
|
msg.Option(ice.MSG_USERROLE, share.Append(aaa.USERROLE))
|
||||||
|
msg.Option(ice.MSG_USERNICK, share.Append(aaa.USERNICK))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,8 +162,19 @@ func init() {
|
|||||||
if msg := m.Cmd(SHARE, m.Option(SHARE)); kit.Int(msg.Append(mdb.TIME)) < kit.Int(msg.FormatTime()) {
|
if msg := m.Cmd(SHARE, m.Option(SHARE)); kit.Int(msg.Append(mdb.TIME)) < kit.Int(msg.FormatTime()) {
|
||||||
m.RenderResult("共享超时")
|
m.RenderResult("共享超时")
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
switch msg.Append(mdb.TYPE) {
|
||||||
|
case LOGIN:
|
||||||
|
if sessid := aaa.SessCreate(m, msg.Append(aaa.USERNAME)); m.Option(ice.MSG_USERWEB) == "" {
|
||||||
|
m.RenderRedirect(ice.PS, ice.MSG_SESSID, sessid)
|
||||||
|
} else {
|
||||||
|
RenderCookie(m, sessid)
|
||||||
|
RenderRedirect(m, ice.PS)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
m.RenderIndex(SERVE, ice.VOLCANOS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m.RenderIndex(SERVE, ice.VOLCANOS)
|
|
||||||
}},
|
}},
|
||||||
|
|
||||||
SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
@ -21,20 +21,6 @@ func _header_agent(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _header_check(m *ice.Message, arg ...string) {
|
func _header_check(m *ice.Message, arg ...string) {
|
||||||
if m.Option(web.SHARE) != "" {
|
|
||||||
switch msg := m.Cmd(web.SHARE, m.Option(web.SHARE)); msg.Append(mdb.TYPE) {
|
|
||||||
case web.LOGIN:
|
|
||||||
if m.Option(ice.MSG_USERNAME) != msg.Append(aaa.USERNAME) {
|
|
||||||
web.RenderCookie(m, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME))))
|
|
||||||
m.Option(ice.MSG_USERNICK, aaa.UserNick(m, msg.Append(aaa.USERNAME)))
|
|
||||||
}
|
|
||||||
case web.STORM:
|
|
||||||
m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME))
|
|
||||||
case web.FIELD:
|
|
||||||
m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.Option(ice.MSG_USERNAME) == "" {
|
if m.Option(ice.MSG_USERNAME) == "" {
|
||||||
m.Option(web.LOGIN, m.Config(web.LOGIN))
|
m.Option(web.LOGIN, m.Config(web.LOGIN))
|
||||||
m.Option(web.SSO, m.Conf(web.SERVE, kit.Keym(web.SSO)))
|
m.Option(web.SSO, m.Conf(web.SERVE, kit.Keym(web.SSO)))
|
||||||
@ -143,9 +129,8 @@ func init() {
|
|||||||
m.Cmdy(code.WEBPACK, mdb.REMOVE)
|
m.Cmdy(code.WEBPACK, mdb.REMOVE)
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(aaa.USERNICK, m.Option(ice.MSG_USERNICK))
|
|
||||||
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
||||||
for _, k := range []string{aaa.LANGUAGE, aaa.BACKGROUND, aaa.AVATAR} {
|
for _, k := range []string{aaa.LANGUAGE, aaa.BACKGROUND, aaa.AVATAR, aaa.USERNICK} {
|
||||||
m.Option(k, msg.Append(k))
|
m.Option(k, msg.Append(k))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user