OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
hps
/
faces
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/28/2024 10:38:34 AM
rwxr-xr-x
📄
.DS_Store
6 KB
10/26/2024 01:24:56 PM
rw-r--r--
📁
.ipynb_checkpoints
-
10/26/2024 01:24:58 PM
rwxr-xr-x
📁
.venv
-
10/26/2024 01:25:02 PM
rwxr-xr-x
📄
app.py
1008 bytes
10/26/2024 01:24:56 PM
rw-r--r--
📄
crop.py
1.5 KB
10/26/2024 01:24:56 PM
rw-r--r--
📄
crop.py.zip
913 bytes
10/26/2024 01:24:56 PM
rw-r--r--
📁
detected
-
10/28/2024 09:39:25 AM
rwxr-xr-x
📁
faces
-
10/26/2024 01:25:02 PM
rwxr-xr-x
📄
faces.sh
98 bytes
10/26/2024 01:24:56 PM
rw-r--r--
📄
find_faces.py
1.42 KB
10/28/2024 09:35:38 AM
rw-r--r--
📁
img
-
10/26/2024 01:24:59 PM
rwxr-xr-x
📄
index.html
1.12 KB
10/26/2024 01:24:56 PM
rw-r--r--
📄
index3.html
5.93 KB
10/26/2024 01:24:57 PM
rw-r--r--
📄
new.py
128 bytes
10/26/2024 01:24:57 PM
rw-r--r--
📄
newtest.php
1.34 KB
10/26/2024 01:24:57 PM
rw-r--r--
📄
people_with_phones.png
88.37 KB
10/26/2024 01:24:57 PM
rw-r--r--
📄
requirements.txt
33 bytes
10/26/2024 01:24:57 PM
rw-r--r--
📄
runpy.php
351 bytes
10/26/2024 01:24:57 PM
rw-r--r--
📄
straighten.py
1.38 KB
10/26/2024 01:24:57 PM
rw-r--r--
📄
test_faces_detected.jpg
2.98 MB
10/26/2024 01:24:58 PM
rw-r--r--
📄
testing.ipynb
6.74 KB
10/26/2024 01:24:57 PM
rw-r--r--
📄
upload.html
1.41 KB
10/28/2024 09:11:41 AM
rw-r--r--
📄
upload.php
4.48 KB
10/28/2024 09:41:43 AM
rw-r--r--
📁
uploads
-
10/28/2024 09:41:46 AM
rwxrwxrwx
Editing: upload.php
Close
<?php // $root = "C:/xampp/htdocs/hps/faces/"; //Localhost for windows // $uploadDir = "C:/xampp/htdocs/hps/faces/uploads/"; //Localhost for windows // $pythonScript = "C:/xampp/htdocs/hps/faces/find_faces.py"; //Localhost for windows // $pythonPath = 'python'; // Adjust this path if necessary $root = "/var/www/cream/hps/faces/"; //Server directory $uploadDir = "/var/www/cream/hps/faces/uploads"; //Server directory $pythonScript = "/var/www/cream/hps/faces/find_faces.py"; //Localhost for windows $pythonPath = '/usr/bin/python3'; // Adjust this path if necessary function uploadImage($fileInputName, $targetDir, $maxFileSize = 5000000, $allowedFormats = ['jpg', 'jpeg', 'png', 'gif']) { global $root; // Check if the target directory exists, create it if not if (!is_dir($targetDir)) { mkdir($targetDir, 0755, true); } // Set the target file path $targetFile = $targetDir . basename($_FILES[$fileInputName]["name"]); $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); // Check if the file is a valid image $check = getimagesize($_FILES[$fileInputName]["tmp_name"]); if ($check === false) { return "File is not an image."; } // Check file size if ($_FILES[$fileInputName]["size"] > $maxFileSize) { return "Sorry, your file is too large."; } // Allow only certain file formats if (!in_array($imageFileType, $allowedFormats)) { return "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; } echo "The target file directory is ".$root . $targetFile; // Attempt to upload the file if (move_uploaded_file($_FILES[$fileInputName]["tmp_name"], $targetFile)) { return $root . $targetFile; // Return the path of the uploaded file } else { return "Sorry, there was an error uploading your file."; } } function executePythonScript($pythonScript, $filePath) { global $pythonPath; $command = escapeshellcmd("$pythonPath $pythonScript " . escapeshellarg($filePath)); echo "<br>".$command."<br>"; exec($command, $output, $returnVar); // Return output and return status return [$output, $returnVar]; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <? if ($_SERVER['REQUEST_METHOD'] == 'POST') { $targetDir = "uploads/"; $uploadedFile = uploadImage('image', $targetDir); // Check if the upload was successful if (strpos($uploadedFile, $uploadDir) === 0) { echo "<br> The Uploaded File Directory is: " . htmlspecialchars($uploadedFile) . "<br>"; // Execute the Python script list($output, $returnVar) = executePythonScript($pythonScript ,$uploadedFile); print_r($output); echo "<br>"; print_r($returnVar); echo "<br>"; // Check if the command executed successfully if ($returnVar === 0) { // Decode the JSON output from the Python script $jsonOutput = implode("", $output); $result = json_decode($jsonOutput, true); // Prepare a response based on the result if ($result['status'] === 'success') { $response = "The file " . htmlspecialchars(basename($uploadedFile)) . " has been processed.<br>"; $response .= "Found Faces: " . $result['found_faces'] . "<br>"; if ($result['found_faces'] > 0) { foreach ($result['faces'] as $face) { $response .= "Face at (x: {$face['x']}, y: {$face['y']}, width: {$face['width']}, height: {$face['height']})<br>"; } } $response .= "Result image saved as: " . htmlspecialchars($result['result_image']) . "<br>"; $response .= "<img src='" . htmlspecialchars($result['result_image']) . "' alt='' style='max-width: 1280px; height: auto;'>"; } else { $response = "Error: " . htmlspecialchars($result['message']); } echo $response; } else { echo "There was an error executing the Python script: " . implode("<br>", $output); } } else { echo $uploadedFile; // Error message from the upload function } } else { echo "Invalid request method."; } ?> </body> </html>