Auto commit: 2025-11-23T18:39:57.826Z
112
api/import.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$response = [
|
||||
'success' => false,
|
||||
'files' => [],
|
||||
'errors' => []
|
||||
];
|
||||
|
||||
function getUploadErrorMessage($errorCode) {
|
||||
switch ($errorCode) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.';
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
return 'The uploaded file was only partially uploaded.';
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
return 'No file was uploaded.';
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
return 'Missing a temporary folder.';
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
return 'Failed to write file to disk.';
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
return 'A PHP extension stopped the file upload.';
|
||||
default:
|
||||
return 'Unknown upload error.';
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_FILES['photos'])) {
|
||||
$response['errors'][] = 'No files were sent. The key "photos" is missing from the request.';
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
$upload_dir = __DIR__ . '/../assets/uploads/';
|
||||
if (!is_dir($upload_dir)) {
|
||||
if (!mkdir($upload_dir, 0775, true)) {
|
||||
$response['errors'][] = 'Failed to create upload directory: ' . $upload_dir;
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_writable($upload_dir)) {
|
||||
$response['errors'][] = 'The upload directory is not writable: ' . $upload_dir;
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
$files = $_FILES['photos'];
|
||||
$file_count = count($files['name']);
|
||||
$successful_uploads = 0;
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
'INSERT INTO photos (filename, filepath, filesize) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE updated_at = CURRENT_TIMESTAMP'
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
$response['errors'][] = 'Database connection failed: ' . $e->getMessage();
|
||||
error_log('DB Connection Error: ' . $e->getMessage());
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
for ($i = 0; $i < $file_count; $i++) {
|
||||
$errorCode = $files['error'][$i];
|
||||
$filename = basename($files['name'][$i]);
|
||||
|
||||
if ($errorCode !== UPLOAD_ERR_OK) {
|
||||
$response['errors'][] = "Error uploading '$filename': " . getUploadErrorMessage($errorCode);
|
||||
continue;
|
||||
}
|
||||
|
||||
$filepath = $upload_dir . $filename;
|
||||
$relative_path = 'assets/uploads/' . $filename;
|
||||
|
||||
if (!move_uploaded_file($files['tmp_name'][$i], $filepath)) {
|
||||
$response['errors'][] = "Failed to move uploaded file '$filename'. Check permissions and paths.";
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt->execute([$filename, $relative_path, $files['size'][$i]]);
|
||||
$response['files'][] = [
|
||||
'filename' => $filename,
|
||||
'filepath' => $relative_path
|
||||
];
|
||||
$successful_uploads++;
|
||||
} catch (PDOException $e) {
|
||||
$response['errors'][] = "Failed to save file '$filename' to database: " . $e->getMessage();
|
||||
error_log("DB Insert Error for $filename: " . $e->getMessage());
|
||||
// Optionally, delete the file if DB insert fails
|
||||
// unlink($filepath);
|
||||
}
|
||||
}
|
||||
|
||||
if ($successful_uploads > 0) {
|
||||
$response['success'] = true;
|
||||
}
|
||||
|
||||
if ($successful_uploads < $file_count) {
|
||||
$response['success'] = false; // Mark as failure if any file failed
|
||||
}
|
||||
|
||||
|
||||
echo json_encode($response);
|
||||
33
api/pexels.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__.'/../includes/pexels.php';
|
||||
$qs = isset($_GET['queries']) ? explode(',', $_GET['queries']) : ['person,face','city,street','nature,mountain','animal,cat','food,pizza'];
|
||||
$out = [];
|
||||
foreach ($qs as $q) {
|
||||
$u = 'https://api.pexels.com/v1/search?query=' . urlencode(trim($q)) . '&orientation=square&per_page=3&page=1';
|
||||
$d = pexels_get($u);
|
||||
if ($d && !empty($d['photos'])) {
|
||||
foreach($d['photos'] as $p) {
|
||||
$src = $p['src']['large'] ?? null;
|
||||
$dest = __DIR__.'/../assets/images/pexels/'.$p['id'].'.jpg';
|
||||
if ($src && !file_exists($dest)) {
|
||||
download_to($src, $dest);
|
||||
}
|
||||
$out[] = [
|
||||
'src' => 'assets/images/pexels/'.$p['id'].'.jpg',
|
||||
'photographer' => $p['photographer'] ?? 'Unknown',
|
||||
'photographer_url' => $p['photographer_url'] ?? '',
|
||||
'alt' => $p['alt'] ?? 'Photo by '.$p['photographer'],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// Fallback: Picsum
|
||||
$out[] = [
|
||||
'src' => 'https://picsum.photos/600/600',
|
||||
'photographer' => 'Random Picsum',
|
||||
'photographer_url' => 'https://picsum.photos/',
|
||||
'alt' => 'Random placeholder image'
|
||||
];
|
||||
}
|
||||
}
|
||||
echo json_encode($out);
|
||||
113
assets/css/custom.css
Normal file
@ -0,0 +1,113 @@
|
||||
/* General Styles */
|
||||
body {
|
||||
font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
||||
transition: background-color 0.3s, color 0.3s;
|
||||
}
|
||||
|
||||
:root {
|
||||
--light-bg: #FFFFFF;
|
||||
--light-surface: #F8F9FA;
|
||||
--light-text-primary: #212529;
|
||||
--light-text-secondary: #6C757D;
|
||||
--dark-bg: #121212;
|
||||
--dark-surface: #1E1E1E;
|
||||
--dark-text-primary: #E9ECEF;
|
||||
--dark-text-secondary: #ADB5BD;
|
||||
--accent-color: #0D6EFD;
|
||||
}
|
||||
|
||||
body.light-theme {
|
||||
background-color: var(--light-bg);
|
||||
color: var(--light-text-primary);
|
||||
}
|
||||
|
||||
body.dark-theme {
|
||||
background-color: var(--dark-bg);
|
||||
color: var(--dark-text-primary);
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
.main-container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
flex-shrink: 0;
|
||||
padding: 1rem;
|
||||
border-right: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
body.light-theme .sidebar {
|
||||
background-color: var(--light-surface);
|
||||
border-right: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
body.dark-theme .sidebar {
|
||||
background-color: var(--dark-surface);
|
||||
border-right: 1px solid #343a40;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex-grow: 1;
|
||||
padding: 1rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
.sidebar h4 {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
color: var(--light-text-secondary);
|
||||
}
|
||||
|
||||
body.dark-theme .sidebar .nav-link {
|
||||
color: var(--dark-text-secondary);
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active,
|
||||
.sidebar .nav-link:hover {
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* Search Bar */
|
||||
.search-bar {
|
||||
flex-grow: 1;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
/* Gallery */
|
||||
.photo-gallery {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.photo-item img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 0.25rem;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.photo-item img:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
/* Theme switcher */
|
||||
.theme-switcher {
|
||||
cursor: pointer;
|
||||
}
|
||||
BIN
assets/images/pexels/1020010.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
assets/images/pexels/1055272.jpg
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/images/pexels/105808.jpg
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
assets/images/pexels/1115804.jpg
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
assets/images/pexels/1292496.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
assets/images/pexels/130574.jpg
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
assets/images/pexels/14229638.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/images/pexels/1454797.jpg
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
assets/images/pexels/1520760.jpg
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
assets/images/pexels/158330.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
assets/images/pexels/1592384.jpg
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
assets/images/pexels/1617366.jpg
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
assets/images/pexels/162396.jpg
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
assets/images/pexels/1715092.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/images/pexels/189361.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
assets/images/pexels/189396.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
assets/images/pexels/2100650.jpg
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
assets/images/pexels/2173872.jpg
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
assets/images/pexels/2393835.jpg
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
assets/images/pexels/2437286.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
assets/images/pexels/259239.jpg
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
assets/images/pexels/2762939.jpg
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
assets/images/pexels/288100.jpg
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
assets/images/pexels/290275.jpg
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
assets/images/pexels/34791005.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
assets/images/pexels/3876394.jpg
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
assets/images/pexels/3944311.jpg
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
assets/images/pexels/399772.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
assets/images/pexels/41953.jpg
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
assets/images/pexels/450038.jpg
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
assets/images/pexels/582070.jpg
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
assets/images/pexels/694587.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
assets/images/pexels/698532.jpg
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
assets/images/pexels/772478.jpg
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
assets/images/pexels/789555.jpg
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
assets/images/pexels/793763.jpg
Normal file
|
After Width: | Height: | Size: 71 KiB |
BIN
assets/images/pexels/8218.jpg
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
assets/images/pexels/831889.jpg
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
assets/images/pexels/87009.jpg
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/images/pexels/87651.jpg
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
assets/images/pexels/892649.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
assets/images/pexels/938580.jpg
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
assets/images/pexels/938582.jpg
Normal file
|
After Width: | Height: | Size: 86 KiB |
92
assets/js/main.js
Normal file
@ -0,0 +1,92 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const themeSwitcher = document.getElementById('theme-switcher');
|
||||
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
|
||||
|
||||
if (currentTheme) {
|
||||
document.body.classList.add(currentTheme);
|
||||
if (currentTheme === 'dark-theme') {
|
||||
themeSwitcher.innerHTML = '<i class="bi bi-sun-fill"></i>';
|
||||
} else {
|
||||
themeSwitcher.innerHTML = '<i class="bi bi-moon-fill"></i>';
|
||||
}
|
||||
} else {
|
||||
// Default to light
|
||||
document.body.classList.add('light-theme');
|
||||
themeSwitcher.innerHTML = '<i class="bi bi-moon-fill"></i>';
|
||||
}
|
||||
|
||||
themeSwitcher.addEventListener('click', () => {
|
||||
if (document.body.classList.contains('dark-theme')) {
|
||||
document.body.classList.remove('dark-theme');
|
||||
document.body.classList.add('light-theme');
|
||||
localStorage.setItem('theme', 'light-theme');
|
||||
themeSwitcher.innerHTML = '<i class="bi bi-moon-fill"></i>';
|
||||
} else {
|
||||
document.body.classList.remove('light-theme');
|
||||
document.body.classList.add('dark-theme');
|
||||
localStorage.setItem('theme', 'dark-theme');
|
||||
themeSwitcher.innerHTML = '<i class="bi bi-sun-fill"></i>';
|
||||
}
|
||||
});
|
||||
|
||||
// Folder import functionality
|
||||
const importFolderBtn = document.getElementById('import-folder-btn');
|
||||
const folderInput = document.getElementById('folder-input');
|
||||
const photoGallery = document.querySelector('.photo-gallery');
|
||||
|
||||
if (importFolderBtn && folderInput && photoGallery) {
|
||||
importFolderBtn.addEventListener('click', () => {
|
||||
folderInput.click();
|
||||
});
|
||||
|
||||
folderInput.addEventListener('change', (event) => {
|
||||
const files = event.target.files;
|
||||
if (files.length > 0) {
|
||||
const formData = new FormData();
|
||||
const imageFiles = Array.from(files).filter(file => file.type.startsWith('image/'));
|
||||
|
||||
if (imageFiles.length > 0) {
|
||||
imageFiles.forEach(file => {
|
||||
formData.append('photos[]', file);
|
||||
});
|
||||
|
||||
// Show a loading indicator
|
||||
photoGallery.innerHTML = '<div class="col"><p>Uploading...</p></div>';
|
||||
|
||||
fetch('api/import.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Server response:', data); // Log the full response
|
||||
photoGallery.innerHTML = ''; // Clear loading indicator
|
||||
|
||||
if (data.success && data.files.length > 0) {
|
||||
// On success, refresh the page to show all images from the DB
|
||||
window.location.reload();
|
||||
} else {
|
||||
let errorMessages = 'Upload failed. Please try again.';
|
||||
if (data.errors && data.errors.length > 0) {
|
||||
// Create a list of error messages
|
||||
errorMessages = '<ul>';
|
||||
data.errors.forEach(err => {
|
||||
errorMessages += `<li>${err}</li>`;
|
||||
});
|
||||
errorMessages += '</ul>';
|
||||
}
|
||||
photoGallery.innerHTML = `<div class="col"><p><strong>Upload Failed:</strong></p>${errorMessages}</div>`;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error uploading files:', error);
|
||||
photoGallery.innerHTML = '<div class="col"><p>An error occurred during upload. Check the browser console for details.</p></div>';
|
||||
});
|
||||
|
||||
} else {
|
||||
photoGallery.innerHTML = '<div class="col"><p>No images found in the selected folder.</p></div>';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
BIN
assets/uploads/Screenshot 2025-07-22 211239.png
Normal file
|
After Width: | Height: | Size: 506 KiB |
BIN
assets/uploads/Screenshot 2025-07-22 235340.png
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
assets/uploads/Screenshot 2025-07-23 005726.png
Normal file
|
After Width: | Height: | Size: 654 KiB |
BIN
assets/uploads/Screenshot 2025-07-24 013427.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
assets/uploads/Screenshot 2025-07-25 193641.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
assets/uploads/Screenshot 2025-07-25 194057.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
assets/uploads/Screenshot 2025-07-25 194137.png
Normal file
|
After Width: | Height: | Size: 149 KiB |
BIN
assets/uploads/Screenshot 2025-07-26 185850.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
assets/uploads/Screenshot 2025-07-26 190723.png
Normal file
|
After Width: | Height: | Size: 127 KiB |
BIN
assets/uploads/Screenshot 2025-07-27 234510.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
assets/uploads/Screenshot 2025-07-29 223254.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
assets/uploads/Screenshot 2025-07-29 223411.png
Normal file
|
After Width: | Height: | Size: 114 KiB |
BIN
assets/uploads/Screenshot 2025-07-29 223436.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
assets/uploads/Screenshot 2025-07-30 032808.png
Normal file
|
After Width: | Height: | Size: 863 KiB |
BIN
assets/uploads/Screenshot 2025-08-02 154654.png
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
assets/uploads/Screenshot 2025-08-08 022129.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
assets/uploads/Screenshot 2025-08-10 223842.png
Normal file
|
After Width: | Height: | Size: 549 KiB |
BIN
assets/uploads/Screenshot 2025-08-10 224208.png
Normal file
|
After Width: | Height: | Size: 445 KiB |
BIN
assets/uploads/Screenshot 2025-08-11 164103.png
Normal file
|
After Width: | Height: | Size: 245 KiB |
BIN
assets/uploads/Screenshot 2025-08-25 003007.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
24
db/migrations/001_create_photos_table.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config.php';
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$sql = "
|
||||
CREATE TABLE IF NOT EXISTS `photos` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`filename` VARCHAR(255) NOT NULL,
|
||||
`filepath` VARCHAR(1024) NOT NULL,
|
||||
`thumbnail_path` VARCHAR(1024),
|
||||
`filesize` INT,
|
||||
`width` INT,
|
||||
`height` INT,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY `filepath_idx` (`filepath`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
";
|
||||
$pdo->exec($sql);
|
||||
echo "Table 'photos' created successfully." . PHP_EOL;
|
||||
} catch (PDOException $e) {
|
||||
die("DB ERROR: " . $e->getMessage());
|
||||
}
|
||||
26
includes/pexels.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
// includes/pexels.php
|
||||
function pexels_key() {
|
||||
$k = getenv('PEXELS_KEY');
|
||||
return $k && strlen($k) > 0 ? $k : 'Vc99rnmOhHhJAbgGQoKLZtsaIVfkeownoQNbTj78VemUjKh08ZYRbf18';
|
||||
}
|
||||
function pexels_get($url) {
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [ 'Authorization: '. pexels_key() ],
|
||||
CURLOPT_TIMEOUT => 15,
|
||||
]);
|
||||
$resp = curl_exec($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($code >= 200 && $code < 300 && $resp) return json_decode($resp, true);
|
||||
return null;
|
||||
}
|
||||
function download_to($srcUrl, $destPath) {
|
||||
$data = file_get_contents($srcUrl);
|
||||
if ($data === false) return false;
|
||||
if (!is_dir(dirname($destPath))) mkdir(dirname($destPath), 0775, true);
|
||||
return file_put_contents($destPath, $data) !== false;
|
||||
}
|
||||
240
index.php
@ -1,150 +1,108 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query('SELECT * FROM photos ORDER BY created_at DESC');
|
||||
$images = $stmt->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
// Handle DB error
|
||||
$images = [];
|
||||
// You might want to log an error here
|
||||
}
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'Photo App'); ?></title>
|
||||
<meta name="description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'A Windows photos app like Google Photos'); ?>">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Bootstrap Icons -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
<body class="light-theme">
|
||||
|
||||
<div class="main-container">
|
||||
<aside class="sidebar">
|
||||
<h4 class="mb-4">My Photos</h4>
|
||||
|
||||
<div class="px-3 mb-3">
|
||||
<button id="import-folder-btn" class="btn btn-primary w-100"><i class="bi bi-folder-plus me-2"></i> Import Folder</button>
|
||||
<input type="file" id="folder-input" webkitdirectory directory multiple style="display: none;" />
|
||||
</div>
|
||||
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#"><i class="bi bi-image me-2"></i> Photos</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#"><i class="bi bi-star me-2"></i> Favorites</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#"><i class="bi bi-images me-2"></i> Albums</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<h6>Filters</h6>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#"><i class="bi bi-people me-2"></i> Faces</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#"><i class="bi bi-geo-alt me-2"></i> Places</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#"><i class="bi bi-tag me-2"></i> Things</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="position-absolute bottom-0 mb-3">
|
||||
<a class="nav-link" href="#"><i class="bi bi-gear me-2"></i> Settings</a>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="main-content">
|
||||
<header class="header">
|
||||
<div class="search-bar">
|
||||
<input type="search" class="form-control" placeholder="Search photos, people, places...">
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<div id="theme-switcher" class="theme-switcher fs-4">
|
||||
<i class="bi bi-moon-fill"></i>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="photo-gallery">
|
||||
<?php if (!empty($images)):
|
||||
foreach ($images as $image):
|
||||
?>
|
||||
<div class="photo-item">
|
||||
<img src="<?php echo htmlspecialchars($image['filepath']); ?>" alt="<?php echo htmlspecialchars($image['filename']); ?>" loading="lazy">
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
else:
|
||||
?>
|
||||
<div class="col">
|
||||
<p>No images found. Please import photos to see them here.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
|
||||
<!-- Custom JS -->
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||