Compare commits

...

2 Commits

Author SHA1 Message Date
00f2953e7f fix 2 2025-10-18 21:32:14 +02:00
2c9da94143 fix 1 2025-10-18 21:13:20 +02:00
5 changed files with 10 additions and 5 deletions

View File

@@ -38,7 +38,6 @@ func adminLoginHandler(w http.ResponseWriter, r *http.Request) {
Value: base64.StdEncoding.EncodeToString([]byte(username + ":" + hashPassword(password))), Value: base64.StdEncoding.EncodeToString([]byte(username + ":" + hashPassword(password))),
Path: "/admin/", Path: "/admin/",
HttpOnly: true, HttpOnly: true,
MaxAge: 3600,
}) })
http.Redirect(w, r, "/admin/", http.StatusSeeOther) http.Redirect(w, r, "/admin/", http.StatusSeeOther)
} }
@@ -309,7 +308,7 @@ func AdminRouteHandler(w http.ResponseWriter, r *http.Request) {
var routes []AdminRouteTemplateS var routes []AdminRouteTemplateS
for _, level := range difficultyLevels { for _, level := range difficultyLevels {
var route AdminRouteTemplateS var route AdminRouteTemplateS
rows, err := db.Query("SELECT tasks.id, tasks.order_num, CIPHERS.assignment, CIPHERS.clue, tasks.end_clue, POSITIONS.gps, POSITIONS.clue, CIPHERS.solution FROM TASKS JOIN CIPHERS ON TASKS.cipher_id = ciphers.id JOIN POSITIONS on TASKS.position_id = POSITIONS.id WHERE TASKS.difficulty_level=? ORDER BY TASKS.order_num;", level.ID) rows, err := db.Query("SELECT tasks.id, tasks.order_num, CIPHERS.assignment, CIPHERS.clue, tasks.end_clue, POSITIONS.gps, POSITIONS.clue, CIPHERS.solution, COALESCE(QR_CODES.uid, '') FROM TASKS JOIN CIPHERS ON TASKS.cipher_id = ciphers.id JOIN POSITIONS on TASKS.position_id = POSITIONS.id LEFT JOIN QR_CODES ON QR_CODES.position_id = POSITIONS.id WHERE TASKS.difficulty_level=? ORDER BY TASKS.order_num;", level.ID)
if err != nil { if err != nil {
http.Error(w, "Database error", http.StatusInternalServerError) http.Error(w, "Database error", http.StatusInternalServerError)
return return
@@ -318,10 +317,11 @@ func AdminRouteHandler(w http.ResponseWriter, r *http.Request) {
route.Name = level.LevelName route.Name = level.LevelName
for rows.Next() { for rows.Next() {
var cipher CipherTemplateS var cipher CipherTemplateS
if err := rows.Scan(&cipher.ID, &cipher.Order, &cipher.Assignment, &cipher.HelpText, &cipher.FinalClue, &cipher.Coordinates, &cipher.PositionHint, &cipher.Solution); err != nil { if err := rows.Scan(&cipher.ID, &cipher.Order, &cipher.Assignment, &cipher.HelpText, &cipher.FinalClue, &cipher.Coordinates, &cipher.PositionHint, &cipher.Solution, &cipher.URL); err != nil {
http.Error(w, "Database error", http.StatusInternalServerError) http.Error(w, "Database error", http.StatusInternalServerError)
return return
} }
cipher.URL = domain + "/qr/" + cipher.URL
route.Ciphers = append(route.Ciphers, cipher) route.Ciphers = append(route.Ciphers, cipher)
} }
if err := rows.Err(); err != nil { if err := rows.Err(); err != nil {

View File

@@ -211,7 +211,7 @@ func qrHandler(w http.ResponseWriter, r *http.Request) {
} }
CipherTemplateData := CipherTemplateS{ CipherTemplateData := CipherTemplateS{
Order: uint(cipherID), Order: uint(order),
Assignment: template.HTML(assignment), Assignment: template.HTML(assignment),
HelpText: "", HelpText: "",
FinalClue: "", FinalClue: "",

View File

@@ -15,6 +15,7 @@ type CipherTemplateS struct {
Solution string Solution string
Help int Help int
Wrong bool Wrong bool
URL string
} }
type TeamTemplateS struct { type TeamTemplateS struct {

View File

@@ -17,7 +17,7 @@
</tr> </tr>
{{range .QRs}} {{range .QRs}}
<tr> <tr>
<td>{{.URL}}</td> <td><a href="{{.URL}}">{{.URL}}</a></td>
<td>{{.Position}}</td> <td>{{.Position}}</td>
<td>{{.GPS}}</td> <td>{{.GPS}}</td>
<td> <td>

View File

@@ -12,6 +12,7 @@
<h2>{{.Name}}</h2> <h2>{{.Name}}</h2>
<table border="1"> <table border="1">
<tr> <tr>
<th>ID</th>
<th>Pořadí</th> <th>Pořadí</th>
<th>Souřadnice</th> <th>Souřadnice</th>
<th>Nápověda pozice</th> <th>Nápověda pozice</th>
@@ -19,10 +20,12 @@
<th>Nápověda</th> <th>Nápověda</th>
<th>Řešení</th> <th>Řešení</th>
<th>Cílová indicie</th> <th>Cílová indicie</th>
<th>URL</th>
<th>Smazat</th> <th>Smazat</th>
</tr> </tr>
{{range .Ciphers}} {{range .Ciphers}}
<tr> <tr>
<td>{{.ID}}</td>
<td>{{.Order}}</td> <td>{{.Order}}</td>
<td>{{.Coordinates}}</td> <td>{{.Coordinates}}</td>
<td>{{.PositionHint}}</td> <td>{{.PositionHint}}</td>
@@ -30,6 +33,7 @@
<td>{{.HelpText}}</td> <td>{{.HelpText}}</td>
<td>{{.Solution}}</td> <td>{{.Solution}}</td>
<td>{{.FinalClue}}</td> <td>{{.FinalClue}}</td>
<td><a href="{{.URL}}">{{.URL}}</a></td>
<td> <td>
<form action="/admin/routes" method="post"> <form action="/admin/routes" method="post">
<input type="hidden" name="delete" value="{{.ID}}"> <input type="hidden" name="delete" value="{{.ID}}">