Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package portal
import (
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/Tea"
"net/http"
"os"
"regexp"
"strings"
)
type WildcardAction struct {
actionutils.PortalAction
}
func (this *WildcardAction) Init() {
this.Nav("", "", "")
}
func (this *WildcardAction) RunGet(params struct {
Filename string
}) {
var pieces = strings.Split(params.Filename, "/")
var reg = regexp.MustCompile(`^[@\w+.]+$`)
for _, piece := range pieces {
if !reg.MatchString(piece) {
this.ResponseWriter.Header().Set("Content-Type", "text/plain; charset=utf-8") // prevent html injection
this.ResponseWriter.WriteHeader(http.StatusBadRequest)
this.WriteString("invalid url '" + params.Filename + "'")
return
}
}
// check file
var paths = []string{
"/portal/" + params.Filename + ".html",
"/portal/" + params.Filename + "/index.html",
}
var foundPath string
var found = false
for _, path := range paths {
_, err := os.Stat(Tea.Root + path)
if err == nil {
found = true
foundPath = path
break
}
}
if !found {
this.ResponseWriter.WriteHeader(http.StatusNotFound)
this.WriteString("page not found '" + params.Filename + "'")
return
}
this.View(foundPath)
this.Show()
}