Add files via upload

This commit is contained in:
Tomáš Dvořák
2025-05-21 13:21:46 +02:00
committed by GitHub
parent db484a637b
commit 4d0f7d9b2e
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -148,7 +148,7 @@
<p class="text-xs text-gray-500 mb-2">Systém pro správu a sledování firemních úkolů</p>
</div>
</div>
<button onclick="openWindowsFolder('M:\\10. MANAGEMENT ÚKOLŮ')" class="block w-full text-center bg-gray-200 hover:bg-gray-300 text-gray-700 text-sm py-1 px-3 rounded transition-colors mt-2">
<button onclick="openWindowsFolder('C:\\Users\\conta\\Downloads\\PROG+HTML')" class="block w-full text-center bg-gray-200 hover:bg-gray-300 text-gray-700 text-sm py-1 px-3 rounded transition-colors mt-2">
<i class="fas fa-folder-open mr-1"></i> Otevřít složku
</button>
</div>
+9 -9
View File
@@ -162,7 +162,7 @@ func handleSubmit(w http.ResponseWriter, r *http.Request) {
// handleOpenFolder opens a Windows Explorer window to the specified folder path
func handleOpenFolder(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
// Only allow POST requests
if r.Method != http.MethodPost {
if r.Method == http.MethodOptions {
@@ -173,12 +173,12 @@ func handleOpenFolder(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]string{"error": "Only POST method is allowed"})
return
}
// Parse the request body
type FolderRequest struct {
Path string `json:"path"`
}
var req FolderRequest
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil {
@@ -187,25 +187,25 @@ func handleOpenFolder(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]string{"error": "Failed to parse request body"})
return
}
// Validate the folder path
if req.Path == "" {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(map[string]string{"error": "Path is required"})
return
}
// Sanitize the path (basic security - you might want to add more validation)
// Ensure it's a valid Windows network path
if !strings.HasPrefix(req.Path, "M:\\") {
if !strings.HasPrefix(req.Path, "C:\\") {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(map[string]string{"error": "Only network paths on M: drive are allowed"})
return
}
// Construct the command to open Windows Explorer
cmd := exec.Command("explorer.exe", req.Path)
// Run the command
err = cmd.Start()
if err != nil {
@@ -214,7 +214,7 @@ func handleOpenFolder(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]string{"error": fmt.Sprintf("Failed to open folder: %v", err)})
return
}
// Send a success response
json.NewEncoder(w).Encode(map[string]string{"status": "success", "message": "Folder opened successfully"})
}