Skip to content

Rjh branch #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions final/config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ return [
'ftp_pass' => "FTP_PASS",
'ftp_port' => "21",
'ftp_domain' => 'FTP_DOMAIN',
'ftp_path' => 'FTP_PATH,
'db_host' => 'DB_HOST',
'db_user' => 'DB_USER',
'db_pwd' => 'DB_PWD',
'db_name' => 'DB_NAME',
'api_key' => 'API_KEY',
'api_secret' => 'API_SECRET'
];
116 changes: 111 additions & 5 deletions final/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ body {
color: #ffffff;
float: right;
text-decoration: none;
padding-right: 20px;
}
.container {
margin-top: 70px;
Expand All @@ -25,13 +26,16 @@ form {
padding: 20px;
border-radius: 5px;
}
label, input, button {
label,
input,
button {
display: block;
width: 100%;
margin-bottom: 10px;
color: #ffffff;
}
input, button {
input,
button {
padding: 10px;
background-color: #333333;
border: none;
Expand All @@ -57,20 +61,31 @@ button {
margin: 0 auto;
}
@keyframes bounce {
0%, 100% {
0%,
100% {
transform: translateY(0);
}
50% {
transform: translateY(-20px);
}
}
.debug-window {
.debug-window,
.metadata-review,
#display-metadata-btn-container {
background-color: #1f1f1f;
padding: 10px;
margin-top: 20px;
max-height: 200px;
overflow-y: scroll;
}

.debug-window {
display: none;
max-height: 200px;
}

.metadata-review {
max-height: 1000px;
}
#tags-container {
margin-top: 20px;
}
Expand All @@ -80,6 +95,8 @@ button {
}
.tag-list li {
margin-bottom: 5px;
display: flex;
justify-content: space-between;
}
#drop-area {
border: 2px dashed #ffffff;
Expand All @@ -100,9 +117,98 @@ button {
.image-preview {
margin-top: 20px;
text-align: center;
max-width: 100%;
width: 100%;
}

.image-preview img {
max-width: 100%;
height: auto;
}

#auth-actions {
display: flex;
}

#auth-actions button {
margin: 0 5px;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

table th,
table td {
padding: 12px;
text-align: left;
border: 1px solid #ddd;
font-size: 1rem;
}

.category-title {
background-color: #fafafa;
padding: 12px;
border-radius: 6px;
margin-top: 30px;
color: #333;
font-size: 1.3rem;
}

.category-title::before {
content: "🔍";
padding-right: 8px;
}

.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
background-color: #1f1f1f;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 900px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
border-radius: 8px;
}

.close {
color: #aaa;
font-size: 28px;
font-weight: bold;
position: absolute;
top: 100px;
right: 25px;
transition: 0.3s;
}

.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}

#display-metadata-btn-container {
display: none;
}

#displayMetadataBtn {
margin-top: 20px;
}
15 changes: 15 additions & 0 deletions final/db.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$config = include 'config.php';

$server = $config['db_host'];
$userid = $config['db_user'];
$pw = $config['db_pwd'];
$db_name = $config['db_name'];

try {
$conn = new PDO("mysql:host=$server;dbname=$db_name", $userid, $pw);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("Connection failed: " . $e->getMessage());
}
?>
99 changes: 99 additions & 0 deletions final/display_metadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();

$config = include 'config.php';
$ftp_domain = $config['ftp_domain'];

if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
header('HTTP/1.1 401 Unauthorized');
exit;
}

$file_name = $_SESSION['file_name'];
$base_name = pathinfo($file_name, PATHINFO_FILENAME);

$image_url = $ftp_domain . "/uploads/". $base_name . '_modified_image.jpg';
$temp_image_path = sys_get_temp_dir() . '/' . basename($image_url);

if (empty($image_url)) {
echo "<p>Error: Image path is not set in the session.</p>";
exit;
}

try {
$image_data = file_get_contents($image_url);
if ($image_data === false) {
throw new Exception('Failed to download the image file.');
}
file_put_contents($temp_image_path, $image_data);

if (!class_exists('Imagick')) {
throw new Exception('Imagick extension is not installed or enabled.');
}

$imagick = new Imagick($temp_image_path);

if (!$imagick) {
echo "<p>Error: Imagick failed to load the image.</p>";
exit;
}

$properties = $imagick->getImageProperties();

$categories = [
'EXIF' => [],
'JPEG' => [],
'IPTC' => [],
'XMP' => [],
'Other' => []
];

foreach ($properties as $key => $value) {
if (strpos($key, 'exif:') === 0) {
$categories['EXIF'][$key] = $value;
} elseif (strpos($key, 'jpeg:') === 0) {
$categories['JPEG'][$key] = $value;
} elseif (strpos($key, 'iptc:') === 0) {
$categories['IPTC'][$key] = $value;
} elseif (strpos($key, 'xmp:') === 0) {
$categories['XMP'][$key] = $value;
} else {
$categories['Other'][$key] = $value;
}
}

echo "<h2>=== Image Metadata ===</h2>";
foreach ($categories as $category => $properties) {
if (!empty($properties)) {
echo "<div class='category-title'><strong>$category Metadata</strong></div>";
echo "<table>
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>";

foreach ($properties as $key => $value) {
$formatted_key = ucfirst(str_replace(['exif:', 'jpeg:', 'iptc:', 'xmp:'], '', $key));
echo "<tr><td>$formatted_key</td><td>$value</td></tr>";
}

echo "</tbody>
</table>";
}
}
$imagick->destroy();
if (file_exists($temp_image_path)) {
unlink($temp_image_path);
}
} catch (Exception $e) {
echo "<p>Error using Imagick: " . $e->getMessage() . "</p>";
if (file_exists($temp_image_path)) {
unlink($temp_image_path);
}
}
?>
Loading