mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 12:32:59 +00:00
now it works maybe
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@@ -114,6 +115,18 @@ func initDefaultBanner() {
|
|||||||
saveBannerData()
|
saveBannerData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to convert string to int with default value
|
||||||
|
func parseIntOrDefault(str string, defaultValue int) int {
|
||||||
|
if str == "" {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
value, err := strconv.Atoi(str)
|
||||||
|
if err != nil {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
func saveBannerData() error {
|
func saveBannerData() error {
|
||||||
bannerLock.Lock()
|
bannerLock.Lock()
|
||||||
defer bannerLock.Unlock()
|
defer bannerLock.Unlock()
|
||||||
@@ -191,8 +204,8 @@ func UpdateBannerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
IsVisible: r.FormValue("style[isVisible]") == "true",
|
IsVisible: r.FormValue("style[isVisible]") == "true",
|
||||||
// Add image position fields
|
// Add image position fields
|
||||||
ImagePosition: r.FormValue("style[imagePosition]"),
|
ImagePosition: r.FormValue("style[imagePosition]"),
|
||||||
ImageX: r.FormValue("style[imageX]"),
|
ImageX: parseIntOrDefault(r.FormValue("style[imageX]"), 0),
|
||||||
ImageY: r.FormValue("style[imageY]"),
|
ImageY: parseIntOrDefault(r.FormValue("style[imageY]"), 0),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user