From 64242ef72398608896ca60d2cbfe725e9b116703 Mon Sep 17 00:00:00 2001 From: xoy Date: Sun, 26 Feb 2023 13:43:36 +0100 Subject: [PATCH] php umsetzung anfang --- .DS_Store | Bin 0 -> 6148 bytes README.md | 7 - web/pages/about.html => about.php | 4 +- config/database.yml | 5 - config/http.yml | 1 - ctdo.go | 61 ------- ctdo.sql | 13 -- database.go | 39 ----- web/pages/datenschutz.html => datenschutz.php | 0 elements/nav.html | 11 ++ web/pages/event.html => event.php | 0 events.go | 75 --------- web/pages/events.html => events.php | 0 file.go | 48 ------ func.go | 42 ----- go.mod | 5 - go.sum | 2 - html.go | 106 ------------ http.go | 110 ------------ {web/images => images}/adresse_knopf.webp | Bin {web/images => images}/chat_knopf.webp | Bin {web/images => images}/header.jpg | Bin {web/images => images}/logo_ctdo.svg | 0 {web/images => images}/mail_knopf.webp | Bin {web/images => images}/tel_knopf.webp | Bin web/pages/impressum.html => impressum.php | 0 web/pages/home.html => index.php | 12 +- web/pages/kontakt.html => kontakt.php | 0 kontakt/.DS_Store | Bin 0 -> 6148 bytes {web/pages/kontakt => kontakt}/adresse.html | 0 {web/pages/kontakt => kontakt}/irc.html | 0 {web/pages/kontakt => kontakt}/mail.html | 0 {web/pages/kontakt => kontakt}/tel.html | 0 logger.go | 21 --- main.go | 158 ------------------ php/generator.php | 7 + structs.go | 28 ---- {web/styles => styles}/dashboard.css | 0 {web/styles => styles}/events.css | 0 {web/styles => styles}/home.css | 0 {web/styles => styles}/kontakt.css | 0 {web/styles => styles}/main.css | 0 web/pages/support.html => support.php | 0 tester.go | 5 - web/pages/treff.html => treff.php | 0 web/pages/verein.html => verein.php | 0 web/pages/admin/dashboard.html | 33 ---- yml.go | 55 ------ 48 files changed, 31 insertions(+), 817 deletions(-) create mode 100644 .DS_Store delete mode 100644 README.md rename web/pages/about.html => about.php (99%) delete mode 100644 config/database.yml delete mode 100644 config/http.yml delete mode 100644 ctdo.go delete mode 100644 ctdo.sql delete mode 100644 database.go rename web/pages/datenschutz.html => datenschutz.php (100%) create mode 100644 elements/nav.html rename web/pages/event.html => event.php (100%) delete mode 100644 events.go rename web/pages/events.html => events.php (100%) delete mode 100644 file.go delete mode 100644 func.go delete mode 100644 go.mod delete mode 100644 go.sum delete mode 100644 html.go delete mode 100644 http.go rename {web/images => images}/adresse_knopf.webp (100%) rename {web/images => images}/chat_knopf.webp (100%) rename {web/images => images}/header.jpg (100%) rename {web/images => images}/logo_ctdo.svg (100%) rename {web/images => images}/mail_knopf.webp (100%) rename {web/images => images}/tel_knopf.webp (100%) rename web/pages/impressum.html => impressum.php (100%) rename web/pages/home.html => index.php (92%) rename web/pages/kontakt.html => kontakt.php (100%) create mode 100644 kontakt/.DS_Store rename {web/pages/kontakt => kontakt}/adresse.html (100%) rename {web/pages/kontakt => kontakt}/irc.html (100%) rename {web/pages/kontakt => kontakt}/mail.html (100%) rename {web/pages/kontakt => kontakt}/tel.html (100%) delete mode 100644 logger.go delete mode 100644 main.go create mode 100644 php/generator.php delete mode 100644 structs.go rename {web/styles => styles}/dashboard.css (100%) rename {web/styles => styles}/events.css (100%) rename {web/styles => styles}/home.css (100%) rename {web/styles => styles}/kontakt.css (100%) rename {web/styles => styles}/main.css (100%) rename web/pages/support.html => support.php (100%) delete mode 100644 tester.go rename web/pages/treff.html => treff.php (100%) rename web/pages/verein.html => verein.php (100%) delete mode 100644 web/pages/admin/dashboard.html delete mode 100644 yml.go diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5298ff5e55d18b5fdd062eb73cb75c83e509e80c GIT binary patch literal 6148 zcmeHKyG{c!5Zr}GM50Ma=>k3=J;f0nB~>~q2$4V{;ZlU&pTbW-O_7S8|6#_vi8#eA z2%%lcp0)R3-$-YBMMNjh^RdWCM22WYrBV@2S4{`*JOFCRaVw9qUfhqTcU>jXU!3CJ zkFe`bo@6cG_P<=&c2CdtJ(gYD&KBJamf`jJ>)Xd>b5Zk}@4Q6v)%$17YxO|3wyV7$ zO-L{h3%23q&mxXrbyQhFUo0llwJ}+0ep8z4%aHd0V__SsnRPaTje2qYnmxfj$F=HXQN( zzr-(7E%N&zF$xBPfq%w;4%%ru!AJSsy7zg!YZKZH8ijtD3IuxZ5r6^Dk&|LHd!i1% X#xWZ*3+GEXFdhPhkm!PeUtr)10N*b7 literal 0 HcmV?d00001 diff --git a/README.md b/README.md deleted file mode 100644 index 5a32771..0000000 --- a/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Readme - -```git clone https://git.ctdo.de/xoy/ctdo.de.git``` - -```cd ./ctdo.de/``` - -```go run .``` \ No newline at end of file diff --git a/web/pages/about.html b/about.php similarity index 99% rename from web/pages/about.html rename to about.php index 23b4ba6..fc5fcda 100644 --- a/web/pages/about.html +++ b/about.php @@ -47,7 +47,9 @@

- !FOOTERNAV +
\ No newline at end of file diff --git a/config/database.yml b/config/database.yml deleted file mode 100644 index 69e8c8f..0000000 --- a/config/database.yml +++ /dev/null @@ -1,5 +0,0 @@ -username: admin -password: password -address: localhost -port: 3306 -database: ctdo \ No newline at end of file diff --git a/config/http.yml b/config/http.yml deleted file mode 100644 index 90829f7..0000000 --- a/config/http.yml +++ /dev/null @@ -1 +0,0 @@ -address: :80 \ No newline at end of file diff --git a/ctdo.go b/ctdo.go deleted file mode 100644 index 72bb3e5..0000000 --- a/ctdo.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "strconv" - "strings" - "time" -) - -// jeden ersten donnerstag und dritten dienstag -func getNextTopic() topic { - date := time.Now() - - var output topic - - for i := 0; i < 31; i++ { - newDate := stringSplit(date.AddDate(0, 0, 1*i).Format(time.UnixDate), " ") - - if newDate[0] == "Thu" || newDate[0] == "Tue" { - dayA, errA := strconv.Atoi(newDate[2]) - errorPanic(errA) - - dayB, errB := strconv.Atoi(newDate[2]) - errorPanic(errB) - - if ifFloatRange(float64(dayA)/7, 0, 1, false, true) || (ifFloatRange(float64(dayB)/7, 2, 3, false, true) && newDate[0] == "Tue") { - output.date = date.AddDate(0, 0, 1*i).Format("02.01.2006") - output.days = i - break - } - } - } - - return output -} - -func getRoomState() status { - var err error - body := httpGetBody("https://status.ctdo.de/api/simple/v2") - - bodyString := string(body) - - temp := []string{} - - bodyString = strings.ReplaceAll(bodyString, "{", "") - bodyString = strings.ReplaceAll(bodyString, "}", "") - - Temp := strings.Split(bodyString, ",") - - for _, element := range Temp { - TEmp := strings.Split(element, ":") - temp = append(temp, TEmp[1]) - } - - roomState := new(status) - - roomState.state = temp[0] == "true" - roomState.power, err = strconv.ParseInt(temp[2], 0, 64) - errorPanic(err) - - return *roomState -} diff --git a/ctdo.sql b/ctdo.sql deleted file mode 100644 index ee3fba7..0000000 --- a/ctdo.sql +++ /dev/null @@ -1,13 +0,0 @@ -create database ctdo; -use ctdo; -create table events ( - id int not null auto_increment, - title varchar(80) not null, - description varchar(500) not null, - media varchar(10000), - date varchar(10) not null, - primary key(id) -); -create table adminKeys ( - adminKey varchar(16) not null -); \ No newline at end of file diff --git a/database.go b/database.go deleted file mode 100644 index f320590..0000000 --- a/database.go +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "database/sql" - "strings" - - _ "github.com/go-sql-driver/mysql" -) - -func dbConnect(username string, password string, address string, port string, database string) *sql.DB { - db, err := sql.Open("mysql", username+":"+password+"@tcp("+address+":"+port+")/"+database) - errorPanic(err) - - return db -} - -func dbClose(database *sql.DB) { - database.Close() -} - -func dbQuerry(database *sql.DB, sqlCode string) *sql.Rows { - results, err := database.Query(sqlCode) - errorPanic(err) - - return results -} - -func ctdoConnect() *sql.DB { - dbValues := readDatabaseYML() - - return dbConnect(dbValues.username, dbValues.password, dbValues.address, dbValues.port, dbValues.database) -} - -func sqlClean(sqlString string) string { - sqlString = strings.ReplaceAll(sqlString, "'", "") - sqlString = strings.ReplaceAll(sqlString, "\"", "") - - return sqlString -} diff --git a/web/pages/datenschutz.html b/datenschutz.php similarity index 100% rename from web/pages/datenschutz.html rename to datenschutz.php diff --git a/elements/nav.html b/elements/nav.html new file mode 100644 index 0000000..bddd69d --- /dev/null +++ b/elements/nav.html @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/web/pages/event.html b/event.php similarity index 100% rename from web/pages/event.html rename to event.php diff --git a/events.go b/events.go deleted file mode 100644 index 03c5c67..0000000 --- a/events.go +++ /dev/null @@ -1,75 +0,0 @@ -package main - -func getEvents() []event { - db := ctdoConnect() - defer dbClose(db) - - rows := dbQuerry(db, "SELECT * FROM events;") - - events := []event{} - - for rows.Next() { - Event := new(event) - err := rows.Scan(&Event.id, &Event.title, &Event.description, &Event.media, &Event.date) - if err != nil { - panic(err.Error()) - } - events = append(events, *Event) - } - - return events -} - -func getEventCount() int { - db := ctdoConnect() - defer dbClose(db) - - row := dbQuerry(db, "SELECT COUNT(*) FROM events;") - - count := 0 - - for row.Next() { - row.Scan(&count) - } - - return count -} - -func addEvent(Event event) bool { - db := ctdoConnect() - defer dbClose(db) - - if len(Event.title) > 80 || len(Event.description) > 500 || len(Event.media) == 10000 || len(Event.date) > 10 { - return false - } - - sqlString := "insert into events (title, description, media, date) values ('" + sqlClean(Event.title) + "', '" + sqlClean(Event.description) + "', '" + sqlClean(Event.media) + "', '" + sqlClean(Event.date) + "');" - - dbQuerry(db, sqlString) - - return true -} - -func getAdminKeys() []string { - db := ctdoConnect() - defer dbClose(db) - - rows := dbQuerry(db, "select * from adminKeys;") - - output := []string{} - - for rows.Next() { - temp := "" - err := rows.Scan(&temp) - if err != nil { - panic(err.Error()) - } - output = append(output, temp) - } - - if len(output) == 0 { - return nil - } - - return output -} diff --git a/web/pages/events.html b/events.php similarity index 100% rename from web/pages/events.html rename to events.php diff --git a/file.go b/file.go deleted file mode 100644 index 0e25ab9..0000000 --- a/file.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "errors" - "io/ioutil" - "os" -) - -func fileRead(src string) string { - content, err := ioutil.ReadFile(src) - - errorPanic(err) - - return string(content) -} - -func fileAddLine(input string, filepath string) { - _, err := os.Stat(filepath) - if errors.Is(err, os.ErrNotExist) { - fileCreate(filepath) - } - - var file *os.File - file, err = os.OpenFile(filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) - errorPanic(err) - - _, err = file.WriteString(input + "\n") - errorPanic(err) -} - -func fileCreate(filepath string) { - _, err := os.Stat(filepath) - if errors.Is(err, os.ErrNotExist) { - _, err := os.Create(filepath) - errorPanic(err) - - logger("fileCreate : file created -> " + filepath) - } -} - -func fileMkDir(folderpath string) { - _, err := os.Stat(folderpath) - if errors.Is(err, os.ErrNotExist) { - err = os.Mkdir(folderpath, 0755) - errorPanic(err) - logger("fileMkDir : folder created -> " + folderpath) - } -} diff --git a/func.go b/func.go deleted file mode 100644 index 0f1f1f3..0000000 --- a/func.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - -import ( - "strings" -) - -func ifFloatRange(variable float64, min float64, max float64, includeMin bool, includeMax bool) bool { - a, b := false, false - - if includeMin { - a = variable >= min - } else { - a = variable > min - } - - if includeMax { - b = variable <= max - } else { - b = variable < max - } - - return a && b -} - -func stringSplit(input string, sep string) []string { - output := *new([]string) - for _, element := range strings.Split(input, sep) { - if element != "" { - output = append(output, element) - } - } - return output -} - -func stringListContains(list []string, searched string) bool { - for _, item := range list { - if item == searched { - return true - } - } - return false -} diff --git a/go.mod b/go.mod deleted file mode 100644 index 01bdd7b..0000000 --- a/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module xoy.dev/ctdo - -go 1.19 - -require github.com/go-sql-driver/mysql v1.7.0 // indirect diff --git a/go.sum b/go.sum deleted file mode 100644 index 7109e4c..0000000 --- a/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= -github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= diff --git a/html.go b/html.go deleted file mode 100644 index 6ee2459..0000000 --- a/html.go +++ /dev/null @@ -1,106 +0,0 @@ -package main - -import ( - "strconv" - "strings" -) - -func htmlElement(tag string, innerHTML string, args string) string { - return "<" + tag + " " + args + ">" + innerHTML + "" -} - -func htmlLinkElement(innerHTML string, destination string, blank bool, args string) string { - b := "" - if blank { - b = "target=\"_blank\" " - } - - return htmlElement("a", innerHTML, " href=\""+destination+"\" "+b+args) -} - -func htmlInputElement(name string, _type string, value string, args string) string { - return "" -} - -func htmlNav(pages [][]string, activePage string) string { - output := "" - - for _, page := range pages { - if page[1] == "/"+activePage || (page[1] == "/home" && activePage == "") { - output += htmlElement("li", htmlLinkElement(page[0], page[1], false, "class=\"active\""), "") - } else { - output += htmlElement("li", htmlLinkElement(page[0], page[1], false, ""), "") - } - } - - return htmlElement("nav", htmlElement("ul", output, ""), "") -} - -func htmlNewBanner(text string, link string) string { - output := "" - - output += htmlElement("div", htmlLinkElement(text, link, true, ""), "class=\"newBanner\"") - - return output -} - -func htmlReplacer(input string, activePage string) string { - output := strings.ReplaceAll(input, "!NAV", htmlNav(getPages(), activePage)) - - if getRoomState().state { - output = strings.ReplaceAll(output, "!RAUMSTATUS", "

Raumstatus: offen

") - } else { - output = strings.ReplaceAll(output, "!RAUMSTATUS", "

Raumstatus: geschlossen

") - } - - output = strings.ReplaceAll(output, "!FOOTERNAV", htmlNav(getFooterPages(), activePage)) - - if getNextTopic().days == 0 { - output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet Heute statt!", "")) - } else if getNextTopic().days == 1 { - output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet Morgen statt!", "class=\"topic\"")+htmlElement("p", "Am "+getNextTopic().date, "class=\"topic\"")) - } else if getNextTopic().days < 10 { - output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet in "+strconv.FormatInt(int64(getNextTopic().days), 10)+" Tagen statt!", "class=\"topic\"")+htmlElement("p", "Am "+getNextTopic().date, "class=\"topic\"")) - } else { - output = strings.ReplaceAll(output, "!TOPICTREFF", htmlElement("h3", "Nächster Topictreff findet in "+string(getNextTopic().days)+" Tagen statt!", "class=\"topic\"")+htmlElement("p", "Am "+getNextTopic().date, "class=\"topic\"")) - } - - events := getEvents() - - if len(events) == 0 { - output = strings.ReplaceAll(output, "!EVENTS", htmlElement("h4", "Keine Events in der nächsten Zeit.", "")) - output = strings.ReplaceAll(output, "!NEXTEVENTS", htmlElement("h4", "Keine Events in der nächsten Zeit.", "")) - } else { - tempA, tempB := "", "" - for i, Event := range events { - if i == 24 { - break - } - - tempA = htmlElement("p", htmlClean(Event.date), "class=\"date\"") - tempA += htmlElement("h2", htmlClean(Event.title), "class=\"title\"") - tempA += htmlElement("p", htmlClean(Event.description), "class=\"desc\"") - tempB += htmlLinkElement(htmlElement("div", tempA, "class=\"event\""), "/event/"+strconv.Itoa(Event.id), false, "class=\"event\"") - tempB += "!SPLIT" - } - output = strings.ReplaceAll(output, "!EVENTS", htmlElement("div", strings.ReplaceAll(tempB, "!SPLIT", ""), "class=\"eventList\"")) - //tempC := strings.Split(tempB, "!SPLIT") - //output = strings.ReplaceAll(output, "!NEXTEVENTS", htmlElement("div", tempC[0]+tempC[1]+tempC[2]+tempC[3], "class=\"eventList\"")) - } - - output = strings.ReplaceAll(output, "!NEWBANNER", htmlNewBanner("Rundgang", "https://www.chaostreff-dortmund.de/rundgang/")) - - if strings.Contains(activePage, "/addEvent") { - output = strings.ReplaceAll(output, "!ADMINKEY", activePage) - } else { - output = strings.ReplaceAll(output, "!ADMINKEY", activePage+"/addEvent") - } - - return output -} - -func htmlClean(htmlString string) string { - htmlString = strings.ReplaceAll(htmlString, "<", "[") - htmlString = strings.ReplaceAll(htmlString, ">", "]") - return htmlString -} diff --git a/http.go b/http.go deleted file mode 100644 index ea533b7..0000000 --- a/http.go +++ /dev/null @@ -1,110 +0,0 @@ -package main - -import ( - "io" - "net/http" - "os" - "strings" - "time" -) - -func httpHandleFunc(urlPath string, filepath string, contentType string) { - urlPath = strings.ToLower(urlPath) - logger(readHttpYML() + "/" + urlPath + " <--> " + filepath + " <" + contentType + ">") - http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) { - logger(r.Method + " request -> " + readHttpYML() + "/" + urlPath + " <" + contentType + ">") - - w.Header().Add("Content-Type", contentType) - - io.WriteString(w, htmlReplacer(fileRead(filepath), urlPath)) - }) -} - -func httpHandleFuncWithPOST(urlPath string, filepath string, contentType string) { - Event := new(event) - logger(readHttpYML() + "/" + urlPath + " <--> " + filepath + " <" + contentType + ">") - http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) { - if r.Method == "POST" { - logger(r.Method + " request -> " + readHttpYML() + "/" + urlPath + " <" + contentType + ">") - - r.ParseMultipartForm(10 << 20) - err := r.ParseMultipartForm(200000) - errorPanic(err) - - formdata := r.MultipartForm - - files := formdata.File["media"] - - if filepath == "./web/pages/admin/dashboard.html" { - logger("----------------ADD EVENT----------------") - title := formdata.Value["title"] - description := formdata.Value["description"] - media := formdata.File["media"] - mediaString := "" - date := formdata.Value["date"] - - if title[0] != "" && description[0] != "" && media != nil && date[0] != "" { - logger("title: " + title[0]) - logger("descrtiption: " + description[0]) - logger("media: " + string(len(media))) - - logger("files uploaded successfully: ") - - for i, _ := range files { - if len(media) > 0 { - mediaString += "," - } - mediaString += "./web/images/" + files[i].Filename - - logger("./web/images/" + files[i].Filename) - } - - Event.id = -1 - Event.title = title[0] - Event.description = description[0] - Event.media = mediaString - Event.date = date[0] - - logger("date: " + date[0]) - - if addEvent(*Event) { - for i, _ := range files { - file, err := files[i].Open() - errorPanic(err) - - out, err := os.Create("./web/images/" + files[i].Filename) - errorPanic(err, "unable to create the file -> '"+"./web/images/"+files[i].Filename+"' : check your write access privilege") - - _, err = io.Copy(out, file) - errorPanic(err) - } - logger("event added!") - handleImages() - } else { - logger("event not added!") - } - } else { - logger("no formdata") - } - logger("----------------ADD END----------------") - } - } - - w.Header().Add("Content-Type", contentType) - - io.WriteString(w, htmlReplacer(fileRead(filepath), urlPath)) - }) -} - -func httpGetBody(url string) []byte { - c := &http.Client{Timeout: 10 * time.Second} - r, err := c.Get(url) - errorPanic(err) - defer r.Body.Close() - - var body []byte - body, err = io.ReadAll(r.Body) - errorPanic(err) - - return body -} diff --git a/web/images/adresse_knopf.webp b/images/adresse_knopf.webp similarity index 100% rename from web/images/adresse_knopf.webp rename to images/adresse_knopf.webp diff --git a/web/images/chat_knopf.webp b/images/chat_knopf.webp similarity index 100% rename from web/images/chat_knopf.webp rename to images/chat_knopf.webp diff --git a/web/images/header.jpg b/images/header.jpg similarity index 100% rename from web/images/header.jpg rename to images/header.jpg diff --git a/web/images/logo_ctdo.svg b/images/logo_ctdo.svg similarity index 100% rename from web/images/logo_ctdo.svg rename to images/logo_ctdo.svg diff --git a/web/images/mail_knopf.webp b/images/mail_knopf.webp similarity index 100% rename from web/images/mail_knopf.webp rename to images/mail_knopf.webp diff --git a/web/images/tel_knopf.webp b/images/tel_knopf.webp similarity index 100% rename from web/images/tel_knopf.webp rename to images/tel_knopf.webp diff --git a/web/pages/impressum.html b/impressum.php similarity index 100% rename from web/pages/impressum.html rename to impressum.php diff --git a/web/pages/home.html b/index.php similarity index 92% rename from web/pages/home.html rename to index.php index d9cd5b2..a620294 100644 --- a/web/pages/home.html +++ b/index.php @@ -4,17 +4,25 @@ + ctdo - home + + + - !NEWBANNER +
+ Rundgang +
+
ctdo logo - !NAV +
+
diff --git a/web/pages/kontakt.html b/kontakt.php similarity index 100% rename from web/pages/kontakt.html rename to kontakt.php diff --git a/kontakt/.DS_Store b/kontakt/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 0 { - for _, key := range keys { - httpHandleFunc("admin/"+key, "./web/pages/admin/dashboard.html", "text/html") - httpHandleFuncWithPOST("admin/"+key+"/addEvent", "./web/pages/admin/dashboard.html", "text/html") - } - } - logger("----------------HANDLE END----------------") - - //events - handleEvents() - - //images - handleImages() - - //styles - logger("----------------HANDLE STYLES----------------") - handleFilesInFolder("style/", "./web/styles/", false) - logger("----------------HANDLE END----------------") - - //pages - logger("----------------HANDLE PAGES----------------") - httpHandleFunc("", "./web/pages/home.html", "text/html") - handleFilesInFolder("", "./web/pages/", true) - logger("----------------HANDLE END----------------") -} - -func handleEvents() { - if getEventCount() > 0 { - logger("----------------HANDLE EVENTS----------------") - events := getEvents() - for _, e := range events { - httpHandleFunc("event/"+strconv.Itoa(e.id), "./web/pages/event.html", "text/html") - } - logger("----------------HANDLE END----------------") - } -} - -func handleImages() { - logger("----------------HANDLE IMAGES----------------") - handleFilesInFolder("image/", "./web/images/", false) - logger("----------------HANDLE END----------------") -} - -var alreadyHandledFiles []string = []string{"./web/pages/admin/dashboard.html", "./web/pages/event.html"} - -func handleFilesInFolder(urlPrefix string, folderpath string, handleWithoutFileSuffix bool) { - if folderpath[len(folderpath)-1] != '/' { - folderpath += "/" - } - files, err := ioutil.ReadDir(folderpath) - errorPanic(err) - - for _, file := range files { - alreadyHandled := stringListContains(alreadyHandledFiles, folderpath+file.Name()) - - if !alreadyHandled { - if !file.IsDir() { - f := strings.Split(file.Name(), ".") - ContentType := f[len(f)-1] - filename := "" - - if handleWithoutFileSuffix { - for index, item := range f { - if index < len(f)-1 { - filename += item - } - } - } else { - filename = file.Name() - } - - switch ContentType { - case "png": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "image/png") - case "webp": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "image/webp") - case "svg": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "image/svg+xml") - case "jpeg": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "image/jpeg") - case "jpg": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "image/jpeg") - case "gif": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "image/gif") - case "css": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "text/css") - case "html": - httpHandleFunc(urlPrefix+filename, folderpath+file.Name(), "text/html") - default: - logger("handleFilesInFolder -> content-type unknown : " + folderpath + file.Name()) - } - alreadyHandledFiles = append(alreadyHandledFiles, folderpath+file.Name()) - } else { - childFolder := file.Name() - handleFilesInFolder(childFolder, folderpath+childFolder, handleWithoutFileSuffix) - } - } else { - logger("handleFilesInFolder -> already handled : " + folderpath + file.Name()) - } - } -} - -func getPages() [][]string { - output := [][]string{} - - output = append(output, []string{"home", "/home"}) - output = append(output, []string{"zeiten & location", "/treff"}) - output = append(output, []string{"events", "/events"}) - output = append(output, []string{"über uns", "/about"}) - output = append(output, []string{"kontakt", "/kontakt"}) - output = append(output, []string{"verein", "/verein"}) - output = append(output, []string{"unterstützung", "/support"}) - - return output -} - -func getFooterPages() [][]string { - output := [][]string{} - - output = append(output, []string{"impressum", "/impressum"}) - output = append(output, []string{"datenschutz", "/datenschutz"}) - - return output -} diff --git a/php/generator.php b/php/generator.php new file mode 100644 index 0000000..25b098f --- /dev/null +++ b/php/generator.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/structs.go b/structs.go deleted file mode 100644 index da7b257..0000000 --- a/structs.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -type status struct { - state bool - lastchange int64 - power int64 -} - -type event struct { - id int - title string - description string - media string - date string -} - -type topic struct { - date string - days int -} - -type database struct { - username string - password string - address string - port string - database string -} diff --git a/web/styles/dashboard.css b/styles/dashboard.css similarity index 100% rename from web/styles/dashboard.css rename to styles/dashboard.css diff --git a/web/styles/events.css b/styles/events.css similarity index 100% rename from web/styles/events.css rename to styles/events.css diff --git a/web/styles/home.css b/styles/home.css similarity index 100% rename from web/styles/home.css rename to styles/home.css diff --git a/web/styles/kontakt.css b/styles/kontakt.css similarity index 100% rename from web/styles/kontakt.css rename to styles/kontakt.css diff --git a/web/styles/main.css b/styles/main.css similarity index 100% rename from web/styles/main.css rename to styles/main.css diff --git a/web/pages/support.html b/support.php similarity index 100% rename from web/pages/support.html rename to support.php diff --git a/tester.go b/tester.go deleted file mode 100644 index 37875a1..0000000 --- a/tester.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -func testFuncOutput(functionOutput any, rightOutput any) bool { - return functionOutput == rightOutput -} diff --git a/web/pages/treff.html b/treff.php similarity index 100% rename from web/pages/treff.html rename to treff.php diff --git a/web/pages/verein.html b/verein.php similarity index 100% rename from web/pages/verein.html rename to verein.php diff --git a/web/pages/admin/dashboard.html b/web/pages/admin/dashboard.html deleted file mode 100644 index 56b82b1..0000000 --- a/web/pages/admin/dashboard.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - ctdo - admin - - - - - -
- ctdo logo - !NAV -
-
- !RAUMSTATUS - !EVENTS - -
-
-
-
-
- -
-
- - - \ No newline at end of file diff --git a/yml.go b/yml.go deleted file mode 100644 index fd61fc3..0000000 --- a/yml.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import "strings" - -func readDatabaseYML() database { - file := fileRead("./config/database.yml") - - rows := [][]string{} - - for _, row := range strings.Split(file, "\n") { - rows = append(rows, strings.Split(row, ": ")) - } - - output := new(database) - - for i, row := range rows { - switch i { - case 0: - output.username = row[1] - case 1: - output.password = row[1] - case 2: - output.address = row[1] - case 3: - output.port = row[1] - case 4: - output.database = row[1] - default: - logger("func.go:259 -> switch-case is out of range") - } - } - - return *output -} - -func readHttpYML() string { - file := fileRead("./config/http.yml") - - rows := [][]string{} - - for _, row := range strings.Split(file, "\n") { - rows = append(rows, strings.Split(row, ": ")) - } - - for i, row := range rows { - switch i { - case 0: - return row[1] - default: - logger("func.go:280 -> switch-case is out of range") - } - } - - return "" -}