mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 12:32:59 +00:00
Add files via upload
This commit is contained in:
+1
-1
@@ -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>
|
<p class="text-xs text-gray-500 mb-2">Systém pro správu a sledování firemních úkolů</p>
|
||||||
</div>
|
</div>
|
||||||
</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
|
<i class="fas fa-folder-open mr-1"></i> Otevřít složku
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ func handleSubmit(w http.ResponseWriter, r *http.Request) {
|
|||||||
// handleOpenFolder opens a Windows Explorer window to the specified folder path
|
// handleOpenFolder opens a Windows Explorer window to the specified folder path
|
||||||
func handleOpenFolder(w http.ResponseWriter, r *http.Request) {
|
func handleOpenFolder(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
// Only allow POST requests
|
// Only allow POST requests
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
if r.Method == http.MethodOptions {
|
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"})
|
json.NewEncoder(w).Encode(map[string]string{"error": "Only POST method is allowed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the request body
|
// Parse the request body
|
||||||
type FolderRequest struct {
|
type FolderRequest struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var req FolderRequest
|
var req FolderRequest
|
||||||
err := json.NewDecoder(r.Body).Decode(&req)
|
err := json.NewDecoder(r.Body).Decode(&req)
|
||||||
if err != nil {
|
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"})
|
json.NewEncoder(w).Encode(map[string]string{"error": "Failed to parse request body"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the folder path
|
// Validate the folder path
|
||||||
if req.Path == "" {
|
if req.Path == "" {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
json.NewEncoder(w).Encode(map[string]string{"error": "Path is required"})
|
json.NewEncoder(w).Encode(map[string]string{"error": "Path is required"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanitize the path (basic security - you might want to add more validation)
|
// Sanitize the path (basic security - you might want to add more validation)
|
||||||
// Ensure it's a valid Windows network path
|
// Ensure it's a valid Windows network path
|
||||||
if !strings.HasPrefix(req.Path, "M:\\") {
|
if !strings.HasPrefix(req.Path, "C:\\") {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
json.NewEncoder(w).Encode(map[string]string{"error": "Only network paths on M: drive are allowed"})
|
json.NewEncoder(w).Encode(map[string]string{"error": "Only network paths on M: drive are allowed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the command to open Windows Explorer
|
// Construct the command to open Windows Explorer
|
||||||
cmd := exec.Command("explorer.exe", req.Path)
|
cmd := exec.Command("explorer.exe", req.Path)
|
||||||
|
|
||||||
// Run the command
|
// Run the command
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
if err != nil {
|
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)})
|
json.NewEncoder(w).Encode(map[string]string{"error": fmt.Sprintf("Failed to open folder: %v", err)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a success response
|
// Send a success response
|
||||||
json.NewEncoder(w).Encode(map[string]string{"status": "success", "message": "Folder opened successfully"})
|
json.NewEncoder(w).Encode(map[string]string{"status": "success", "message": "Folder opened successfully"})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user