Auto commit: 2025-11-20T12:08:26.355Z
This commit is contained in:
parent
8c9bbe0851
commit
2c882d18a4
68
assets/css/custom.css
Normal file
68
assets/css/custom.css
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
body {
|
||||||
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
background-color: #F8F9FA;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
background: linear-gradient(135deg, #0D6EFD, #4D8BF2);
|
||||||
|
color: white;
|
||||||
|
padding: 4rem 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero h1 {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.translation-box {
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 2rem;
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: #0D6EFD;
|
||||||
|
border-color: #0D6EFD;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #0b5ed7;
|
||||||
|
border-color: #0a58ca;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-file-upload {
|
||||||
|
border: 2px dashed #0D6EFD;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
padding: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-file-upload:hover {
|
||||||
|
background-color: #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
#file-upload-filename {
|
||||||
|
margin-top: 1rem;
|
||||||
|
font-style: italic;
|
||||||
|
color: #6c757d;
|
||||||
|
}
|
||||||
|
|
||||||
|
#processing-message {
|
||||||
|
display: none;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
}
|
||||||
105
assets/js/main.js
Normal file
105
assets/js/main.js
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
const fileUploadInput = document.getElementById('document-upload');
|
||||||
|
const fileUploadLabel = document.querySelector('.custom-file-upload');
|
||||||
|
const fileNameDisplay = document.getElementById('file-upload-filename');
|
||||||
|
const translateBtn = document.getElementById('translate-btn');
|
||||||
|
const processingMessage = document.getElementById('processing-message');
|
||||||
|
|
||||||
|
// Trigger file input click when the custom upload area is clicked
|
||||||
|
if(fileUploadLabel) {
|
||||||
|
fileUploadLabel.addEventListener('click', () => {
|
||||||
|
if(fileUploadInput) {
|
||||||
|
fileUploadInput.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update UI when a file is selected
|
||||||
|
if(fileUploadInput) {
|
||||||
|
fileUploadInput.addEventListener('change', () => {
|
||||||
|
if (fileUploadInput.files.length > 0) {
|
||||||
|
const fileName = fileUploadInput.files[0].name;
|
||||||
|
if(fileNameDisplay) {
|
||||||
|
fileNameDisplay.textContent = `Selected file: ${fileName}`;
|
||||||
|
}
|
||||||
|
if(translateBtn) {
|
||||||
|
translateBtn.disabled = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(fileNameDisplay) {
|
||||||
|
fileNameDisplay.textContent = '';
|
||||||
|
}
|
||||||
|
if(translateBtn) {
|
||||||
|
translateBtn.disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle form submission
|
||||||
|
const translationForm = document.getElementById('translation-form');
|
||||||
|
if(translationForm) {
|
||||||
|
translationForm.addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('document', fileUploadInput.files[0]);
|
||||||
|
formData.append('source-lang', document.getElementById('source-lang').value);
|
||||||
|
formData.append('target-lang', document.getElementById('target-lang').value);
|
||||||
|
|
||||||
|
const responseMessageDiv = document.getElementById('response-message');
|
||||||
|
|
||||||
|
if(processingMessage) {
|
||||||
|
processingMessage.style.display = 'block';
|
||||||
|
}
|
||||||
|
if(responseMessageDiv){
|
||||||
|
responseMessageDiv.innerHTML = '';
|
||||||
|
responseMessageDiv.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(translateBtn) {
|
||||||
|
translateBtn.disabled = true;
|
||||||
|
translateBtn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Translating...';
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch('upload.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
if(processingMessage) {
|
||||||
|
processingMessage.style.display = 'none';
|
||||||
|
}
|
||||||
|
if(responseMessageDiv){
|
||||||
|
const alertClass = data.status === 'success' ? 'alert-success' : 'alert-danger';
|
||||||
|
responseMessageDiv.innerHTML = `<div class="alert ${alertClass}" role="alert">${data.message}</div>`;
|
||||||
|
responseMessageDiv.style.display = 'block';
|
||||||
|
}
|
||||||
|
if(translateBtn) {
|
||||||
|
translateBtn.disabled = false;
|
||||||
|
translateBtn.innerHTML = 'Translate';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if(processingMessage) {
|
||||||
|
processingMessage.style.display = 'none';
|
||||||
|
}
|
||||||
|
if(responseMessageDiv){
|
||||||
|
responseMessageDiv.innerHTML = `<div class="alert alert-danger" role="alert">An error occurred during the upload. Please try again.</div>`;
|
||||||
|
responseMessageDiv.style.display = 'block';
|
||||||
|
}
|
||||||
|
if(translateBtn) {
|
||||||
|
translateBtn.disabled = false;
|
||||||
|
translateBtn.innerHTML = 'Translate';
|
||||||
|
}
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
247
index.php
247
index.php
@ -1,150 +1,109 @@
|
|||||||
<?php
|
<!DOCTYPE html>
|
||||||
declare(strict_types=1);
|
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>New Style</title>
|
<title>easyenglishtranslator</title>
|
||||||
<?php
|
<meta name="description" content="Translate text on images and PDF scans easily. Upload your document, choose languages, and let AI provide you with an accurate translation.">
|
||||||
// Read project preview data from environment
|
<meta name="keywords" content="document translator, pdf translator, image translator, ocr translation, ai translation, language tool, easy english translator, Built with Flatlogic Generator">
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
<meta property="og:title" content="easyenglishtranslator">
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
<meta property="og:description" content="Translate text on images and PDF scans easily.">
|
||||||
?>
|
<meta property="og:image" content="">
|
||||||
<?php if ($projectDescription): ?>
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<!-- Meta description -->
|
<meta name="twitter:image" content="">
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
|
||||||
<!-- Open Graph meta tags -->
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
<!-- Twitter meta tags -->
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<?php endif; ?>
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||||
<?php if ($projectImageUrl): ?>
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
<!-- 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>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
|
||||||
<div class="card">
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<div class="container">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<a class="navbar-brand" href="#">
|
||||||
<span class="sr-only">Loading…</span>
|
<i class="bi bi-translate text-primary"></i>
|
||||||
</div>
|
easyenglishtranslator
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
</a>
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
</div>
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
</nav>
|
||||||
</div>
|
|
||||||
</main>
|
<header class="hero">
|
||||||
<footer>
|
<div class="container">
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<h1>Document Translation Made Simple</h1>
|
||||||
</footer>
|
<p class="lead">Upload a PDF or image, select your languages, and let our AI do the rest.</p>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="container my-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<div class="translation-box">
|
||||||
|
<form id="translation-form">
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="document-upload" class="form-label">1. Upload Your Document</label>
|
||||||
|
<div class="custom-file-upload">
|
||||||
|
<i class="bi bi-cloud-arrow-up-fill fs-1 text-primary"></i>
|
||||||
|
<p class="mt-2 mb-0">Click to browse or drag & drop your file here</p>
|
||||||
|
<p class="text-muted small">(PDF, JPG, PNG, TIFF)</p>
|
||||||
|
</div>
|
||||||
|
<input type="file" id="document-upload" class="d-none" accept=".pdf,.jpg,.jpeg,.png,.tiff">
|
||||||
|
<div id="file-upload-filename" class="text-center"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-4">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="source-lang" class="form-label">2. Source Language</label>
|
||||||
|
<select class="form-select" id="source-lang" required>
|
||||||
|
<option selected disabled value="">Choose...</option>
|
||||||
|
<option value="en">English</option>
|
||||||
|
<option value="es">Spanish</option>
|
||||||
|
<option value="fr">French</option>
|
||||||
|
<option value="de">German</option>
|
||||||
|
<option value="auto">Auto-detect</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="target-lang" class="form-label">3. Target Language</label>
|
||||||
|
<select class="form-select" id="target-lang" required>
|
||||||
|
<option selected disabled value="">Choose...</option>
|
||||||
|
<option value="en">English</option>
|
||||||
|
<option value="es">Spanish</option>
|
||||||
|
<option value="fr">French</option>
|
||||||
|
<option value="de">German</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-grid">
|
||||||
|
<button type="submit" id="translate-btn" class="btn btn-primary btn-lg" disabled>
|
||||||
|
<i class="bi bi-stars"></i> Translate
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div id="response-message" class="mt-4"></div>
|
||||||
|
<div id="processing-message" class="alert alert-info mt-4" role="alert" style="display: none;">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div class="spinner-border text-primary me-3" role="status">
|
||||||
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
|
<span>Processing your document... This may take a moment.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="text-center py-4 text-muted">
|
||||||
|
<div class="container">
|
||||||
|
<p>© <?php echo date("Y"); ?> easyenglishtranslator. All Rights Reserved. Built with Flatlogic.</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
54
upload.php
Normal file
54
upload.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
// Simple success/error JSON response
|
||||||
|
function json_response($status, $message, $data = null) {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode([
|
||||||
|
'status' => $status,
|
||||||
|
'message' => $message,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
json_response('error', 'Invalid request method.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_FILES['document']) || $_FILES['document']['error'] == UPLOAD_ERR_NO_FILE) {
|
||||||
|
json_response('error', 'No file was uploaded.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $_FILES['document'];
|
||||||
|
|
||||||
|
// Check for upload errors
|
||||||
|
if ($file['error'] !== UPLOAD_ERR_OK) {
|
||||||
|
$upload_errors = [
|
||||||
|
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
|
||||||
|
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
|
||||||
|
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded.',
|
||||||
|
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
|
||||||
|
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder.',
|
||||||
|
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk.',
|
||||||
|
UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload.',
|
||||||
|
];
|
||||||
|
$error_message = $upload_errors[$file['error']] ?? 'Unknown upload error.';
|
||||||
|
json_response('error', $error_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$upload_dir = __DIR__ . '/uploads/';
|
||||||
|
if (!is_dir($upload_dir)) {
|
||||||
|
if (!mkdir($upload_dir, 0775, true)) {
|
||||||
|
json_response('error', 'Failed to create upload directory.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_name = basename($file['name']);
|
||||||
|
$target_path = $upload_dir . $file_name;
|
||||||
|
|
||||||
|
// Move the file to the uploads directory
|
||||||
|
if (move_uploaded_file($file['tmp_name'], $target_path)) {
|
||||||
|
json_response('success', 'File uploaded successfully.', ['filePath' => 'uploads/' . $file_name]);
|
||||||
|
} else {
|
||||||
|
json_response('error', 'Failed to move uploaded file.');
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
x
Reference in New Issue
Block a user