-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.go
49 lines (37 loc) · 1.07 KB
/
index.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package web
import (
"net/http"
"strconv"
"github.com/aceberg/miniboard/internal/auth"
"github.com/aceberg/miniboard/internal/models"
)
func indexHandler(w http.ResponseWriter, r *http.Request) {
var guiData models.GuiData
guiData.Config = AppConfig
tabStr := r.URL.Query().Get("tab")
var tab int
if tabStr == "" {
tab = 0
} else {
tab, _ = strconv.Atoi(tabStr)
}
AppConfig.LoggedIn = auth.IsLoggedIn(w, r)
if AppConfig.Auth && !AppConfig.LoggedIn && AllLinks.Tabs[tab].Auth {
http.Redirect(w, r, "/login/", 302)
}
guiData.CurrentTab = AllLinks.Tabs[tab].Name
guiData.Links = AllLinks
guiData.Horiz = AllLinks.Tabs[tab].Horiz
if AllLinks.Tabs[tab].Refresh != "" && AllLinks.Tabs[tab].Refresh != "0" {
guiData.Config.WebRefresh = AllLinks.Tabs[tab].Refresh
}
guiData.Panels = make(map[int]models.Panel)
for i, name := range AllLinks.Tabs[tab].Panels {
guiData.Panels[i] = AllLinks.Panels[name]
}
execTemplate(w, "index", guiData)
}
func reloadHandler(w http.ResponseWriter, r *http.Request) {
reloadScans() // webgui.go
http.Redirect(w, r, "/", 302)
}