Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73a17ab8b2 |
49
assets/css/custom.css
Normal file
49
assets/css/custom.css
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* General Body Styles */
|
||||||
|
body {
|
||||||
|
font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
background-color: #F8F9FA;
|
||||||
|
color: #212529;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header Styles */
|
||||||
|
.header-gradient {
|
||||||
|
background: linear-gradient(to right, #0B5ED7, #0D6EFD);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-gradient .navbar-brand {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main container */
|
||||||
|
.main-container {
|
||||||
|
padding-top: 2rem;
|
||||||
|
padding-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Card styles for dashboard elements */
|
||||||
|
.card {
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Table styles */
|
||||||
|
.table {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table thead th {
|
||||||
|
font-weight: 600;
|
||||||
|
border-bottom-width: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Action buttons in table */
|
||||||
|
.btn-action {
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toast notifications */
|
||||||
|
.toast-container {
|
||||||
|
z-index: 1090;
|
||||||
|
}
|
||||||
24
assets/js/main.js
Normal file
24
assets/js/main.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
const scanBtn = document.getElementById('scanRepoBtn');
|
||||||
|
|
||||||
|
if (scanBtn) {
|
||||||
|
scanBtn.addEventListener('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const spinner = scanBtn.querySelector('.spinner-border');
|
||||||
|
const buttonText = scanBtn.querySelector('.button-text');
|
||||||
|
const buttonIcon = scanBtn.querySelector('.bi-search');
|
||||||
|
|
||||||
|
// Show spinner, hide icon, and update text
|
||||||
|
if (spinner) spinner.style.display = 'inline-block';
|
||||||
|
if (buttonIcon) buttonIcon.style.display = 'none';
|
||||||
|
if (buttonText) buttonText.textContent = 'Scanning...';
|
||||||
|
|
||||||
|
// Disable button
|
||||||
|
scanBtn.disabled = true;
|
||||||
|
|
||||||
|
// Redirect to trigger the scan and show success message
|
||||||
|
window.location.href = 'index.php?scan=success';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
6
db/migrations/001_create_users_table.sql
Normal file
6
db/migrations/001_create_users_table.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `users` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`username` VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
`password` VARCHAR(255) NOT NULL,
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
326
index.php
326
index.php
@ -1,150 +1,204 @@
|
|||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
session_start();
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
// If the user is not logged in, redirect to the login page.
|
||||||
$now = date('Y-m-d H:i:s');
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'validators/xml_validator.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scans the repository directory for eCTD sequences.
|
||||||
|
*
|
||||||
|
* @param string $repoPath The path to the repository.
|
||||||
|
* @return array A list of sequences found.
|
||||||
|
*/
|
||||||
|
function scanRepository($repoPath) {
|
||||||
|
$sequences = [];
|
||||||
|
if (!is_dir($repoPath)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = scandir($repoPath);
|
||||||
|
foreach ($items as $item) {
|
||||||
|
if ($item[0] === '.') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$sequencePath = $repoPath . '/' . $item;
|
||||||
|
if (is_dir($sequencePath)) {
|
||||||
|
$xmlPath = $sequencePath . '/index.xml';
|
||||||
|
$productName = 'Unknown';
|
||||||
|
$status = 'Pending Validation';
|
||||||
|
|
||||||
|
if (file_exists($xmlPath)) {
|
||||||
|
$xml_content = file_get_contents($xmlPath);
|
||||||
|
$errors = XmlValidator::validate($xml_content);
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$status = 'Validated';
|
||||||
|
$xml = simplexml_load_string($xml_content);
|
||||||
|
if ($xml) {
|
||||||
|
// Correctly parsing with namespace
|
||||||
|
$namespaces = $xml->getNamespaces(true);
|
||||||
|
$ectd_ns = isset($namespaces['ectd']) ? $namespaces['ectd'] : 'urn:ectd-org:ectd';
|
||||||
|
$xml->registerXPathNamespace('ectd', $ectd_ns);
|
||||||
|
|
||||||
|
// Example of fetching a value, adjust xpath as per actual XML structure
|
||||||
|
$result = $xml->xpath('//product-name'); // Simplified xpath
|
||||||
|
if (empty($result)) {
|
||||||
|
// Try another common path
|
||||||
|
$result = $xml->xpath('//admin/product-name');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($result)) {
|
||||||
|
$productName = (string)$result[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$status = 'Validation Failed';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$status = 'Missing index.xml';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sequences[] = [
|
||||||
|
'id' => $item,
|
||||||
|
'product' => $productName,
|
||||||
|
'status' => $status,
|
||||||
|
'last_scanned' => date('Y-m-d H:i:s'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $sequences;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define the repository path and scan it.
|
||||||
|
$repositoryPath = __DIR__ . '/repository';
|
||||||
|
$sequences = scanRepository($repositoryPath);
|
||||||
|
|
||||||
|
function getStatusBadgeClass($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case 'Validated':
|
||||||
|
return 'bg-success';
|
||||||
|
case 'Validation Failed':
|
||||||
|
return 'bg-danger';
|
||||||
|
case 'Missing index.xml':
|
||||||
|
case 'Invalid XML':
|
||||||
|
return 'bg-danger';
|
||||||
|
case 'Pending Validation':
|
||||||
|
return 'bg-warning text-dark';
|
||||||
|
default:
|
||||||
|
return 'bg-secondary';
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!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>
|
|
||||||
<?php
|
<!-- SEO and Meta Tags -->
|
||||||
// Read project preview data from environment
|
<title><?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'eCTD Submission Manager'); ?></title>
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
<meta name="description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'Manage eCTD submissions and validate file structures efficiently.'); ?>">
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
<meta property="og:title" content="<?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'eCTD Submission Manager'); ?>">
|
||||||
?>
|
<meta property="og:description" content="<?php echo htmlspecialchars($_SERVER['PROJECT_DESCRIPTION'] ?? 'Manage eCTD submissions and validate file structures efficiently.'); ?>">
|
||||||
<?php if ($projectDescription): ?>
|
<meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||||
<!-- Meta description -->
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
<meta name="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">
|
||||||
<!-- Open Graph meta tags -->
|
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<!-- Bootstrap CSS -->
|
||||||
<!-- Twitter meta tags -->
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<!-- Bootstrap Icons -->
|
||||||
<?php endif; ?>
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
|
||||||
<?php if ($projectImageUrl): ?>
|
<!-- Google Fonts (Inter) -->
|
||||||
<!-- 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.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<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">
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
<style>
|
|
||||||
:root {
|
<!-- Custom CSS -->
|
||||||
--bg-color-start: #6a11cb;
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
--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">
|
<!-- Header -->
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<nav class="navbar navbar-expand-lg navbar-dark header-gradient shadow-sm">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<div class="container">
|
||||||
<span class="sr-only">Loading…</span>
|
<a class="navbar-brand" href="#">
|
||||||
|
<i class="bi bi-folder-check"></i>
|
||||||
|
<?php echo htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'eCTD Submission Manager'); ?>
|
||||||
|
</a>
|
||||||
|
<div class="d-flex">
|
||||||
|
<span class="navbar-text me-3">Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?>!</span>
|
||||||
|
<a href="logout.php" class="btn btn-outline-light">Logout</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<!-- Main Content -->
|
||||||
|
<main class="container main-container">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<h1 class="h2">Submissions Dashboard</h1>
|
||||||
|
<button id="scanRepoBtn" class="btn btn-primary d-flex align-items-center">
|
||||||
|
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true" style="display: none;"></span>
|
||||||
|
<i class="bi bi-search"></i>
|
||||||
|
<span class="button-text ms-2">Scan Repository</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (isset($_GET['scan']) && $_GET['scan'] === 'success'): ?>
|
||||||
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
|
<strong>Success!</strong> The repository has been scanned and the dashboard is updated.
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Sequence ID</th>
|
||||||
|
<th>Product</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Last Scanned</th>
|
||||||
|
<th class="text-end">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($sequences as $sequence): ?>
|
||||||
|
<tr>
|
||||||
|
<td><strong><?php echo htmlspecialchars($sequence['id']); ?></strong></td>
|
||||||
|
<td><?php echo htmlspecialchars($sequence['product']); ?></td>
|
||||||
|
<td>
|
||||||
|
<span class="badge rounded-pill <?php echo getStatusBadgeClass($sequence['status']); ?>">
|
||||||
|
<?php echo htmlspecialchars($sequence['status']); ?>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td><?php echo htmlspecialchars($sequence['last_scanned']); ?></td>
|
||||||
|
<td class="text-end">
|
||||||
|
<a href="sequence.php?id=<?php echo htmlspecialchars($sequence['id']); ?>" class="btn btn-outline-secondary btn-sm btn-action" title="View Details">
|
||||||
|
<i class="bi bi-eye"></i> View
|
||||||
|
</a>
|
||||||
|
<button class="btn btn-outline-primary btn-sm btn-action" title="Upload Files">
|
||||||
|
<i class="bi bi-upload"></i> Upload
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</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>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<!-- Bootstrap JS Bundle -->
|
||||||
</footer>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<!-- Custom JS -->
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
68
login.php
Normal file
68
login.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$error = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$username = $_POST['username'] ?? '';
|
||||||
|
$password = $_POST['password'] ?? '';
|
||||||
|
|
||||||
|
if (empty($username) || empty($password)) {
|
||||||
|
$error = 'Please enter both username and password.';
|
||||||
|
} else {
|
||||||
|
$stmt = db()->prepare("SELECT * FROM users WHERE username = ?");
|
||||||
|
$stmt->execute([$username]);
|
||||||
|
$user = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($user && password_verify($password, $user['password'])) {
|
||||||
|
$_SESSION['user_id'] = $user['id'];
|
||||||
|
$_SESSION['username'] = $user['username'];
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$error = 'Invalid username or password.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Login</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4>Login</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if ($error): ?>
|
||||||
|
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="username" class="form-label">Username</label>
|
||||||
|
<input type="text" class="form-control" id="username" name="username" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Login</button>
|
||||||
|
<a href="register.php" class="btn btn-link">Register</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
6
logout.php
Normal file
6
logout.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
session_unset();
|
||||||
|
session_destroy();
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
81
register.php
Normal file
81
register.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$error = '';
|
||||||
|
$success = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$username = $_POST['username'] ?? '';
|
||||||
|
$password = $_POST['password'] ?? '';
|
||||||
|
$confirm_password = $_POST['confirm_password'] ?? '';
|
||||||
|
|
||||||
|
if (empty($username) || empty($password) || empty($confirm_password)) {
|
||||||
|
$error = 'Please fill in all fields.';
|
||||||
|
} elseif ($password !== $confirm_password) {
|
||||||
|
$error = 'Passwords do not match.';
|
||||||
|
} else {
|
||||||
|
$stmt = db()->prepare("SELECT * FROM users WHERE username = ?");
|
||||||
|
$stmt->execute([$username]);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$error = 'Username already exists.';
|
||||||
|
} else {
|
||||||
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
$stmt = db()->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
|
||||||
|
if ($stmt->execute([$username, $hashed_password])) {
|
||||||
|
$success = 'Registration successful! You can now <a href="login.php">login</a>.';
|
||||||
|
} else {
|
||||||
|
$error = 'An error occurred. Please try again.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Register</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4>Register</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if ($error): ?>
|
||||||
|
<div class="alert alert-danger"><?= htmlspecialchars($error) ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($success): ?>
|
||||||
|
<div class="alert alert-success"><?= $success ?></div>
|
||||||
|
<?php else: ?>
|
||||||
|
<form method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="username" class="form-label">Username</label>
|
||||||
|
<input type="text" class="form-control" id="username" name="username" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="confirm_password" class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Register</button>
|
||||||
|
<a href="login.php" class="btn btn-link">Login</a>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
6
repository/0001/index.xml
Normal file
6
repository/0001/index.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ectd:ectd-submission xmlns:ectd="urn:ectd-org:ectd">
|
||||||
|
<admin>
|
||||||
|
<product-name>Product A</product-name>
|
||||||
|
</admin>
|
||||||
|
</ectd:ectd-submission>
|
||||||
6
repository/0002/index.xml
Normal file
6
repository/0002/index.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ectd:ectd-submission xmlns:ectd="urn:ectd-org:ectd">
|
||||||
|
<admin>
|
||||||
|
<product-name>Product B</product-name>
|
||||||
|
</admin>
|
||||||
|
</ectd:ectd-submission>
|
||||||
204
sequence.php
Normal file
204
sequence.php
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// If the user is not logged in, redirect to the login page.
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: login.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sequence.php
|
||||||
|
|
||||||
|
require_once 'validators/xml_validator.php';
|
||||||
|
|
||||||
|
function getSequenceDetails($sequenceId) {
|
||||||
|
$basePath = __DIR__ . '/repository';
|
||||||
|
$sequencePath = $basePath . '/' . $sequenceId;
|
||||||
|
|
||||||
|
if (!is_dir($sequencePath)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$details = [
|
||||||
|
'id' => $sequenceId,
|
||||||
|
'productName' => 'N/A',
|
||||||
|
'status' => 'Unknown',
|
||||||
|
'files' => [],
|
||||||
|
'xml_content' => '',
|
||||||
|
'validation_errors' => []
|
||||||
|
];
|
||||||
|
|
||||||
|
// List files in the directory
|
||||||
|
$files = scandir($sequencePath);
|
||||||
|
$details['files'] = array_diff($files, ['.', '..']);
|
||||||
|
|
||||||
|
$xmlPath = $sequencePath . '/index.xml';
|
||||||
|
if (file_exists($xmlPath)) {
|
||||||
|
$xmlContent = file_get_contents($xmlPath);
|
||||||
|
$details['xml_content'] = htmlspecialchars($xmlContent);
|
||||||
|
$errors = XmlValidator::validate($xmlContent);
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
$details['status'] = 'Validated';
|
||||||
|
$xml = simplexml_load_string($xmlContent);
|
||||||
|
if ($xml) {
|
||||||
|
// Correctly parsing with namespace
|
||||||
|
$namespaces = $xml->getNamespaces(true);
|
||||||
|
$ectd_ns = isset($namespaces['ectd']) ? $namespaces['ectd'] : 'urn:ectd-org:ectd';
|
||||||
|
$xml->registerXPathNamespace('ectd', $ectd_ns);
|
||||||
|
|
||||||
|
// Example of fetching a value, adjust xpath as per actual XML structure
|
||||||
|
$result = $xml->xpath('//product-name'); // Simplified xpath
|
||||||
|
if (empty($result)) {
|
||||||
|
// Try another common path
|
||||||
|
$result = $xml->xpath('//admin/product-name');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($result)) {
|
||||||
|
$details['productName'] = (string)$result[0];
|
||||||
|
} else {
|
||||||
|
$details['productName'] = 'N/A';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$details['status'] = 'Validation Failed';
|
||||||
|
$details['validation_errors'] = $errors;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$details['status'] = 'Missing index.xml';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $details;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sequenceId = isset($_GET['id']) ? basename($_GET['id']) : '';
|
||||||
|
$sequenceDetails = null;
|
||||||
|
$uploadMessage = '';
|
||||||
|
|
||||||
|
// Handle file upload
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['sequenceFile'])) {
|
||||||
|
if (!empty($sequenceId) && is_numeric($sequenceId)) {
|
||||||
|
$targetDir = __DIR__ . '/repository/' . $sequenceId . '/';
|
||||||
|
if (!is_dir($targetDir)) {
|
||||||
|
mkdir($targetDir, 0775, true);
|
||||||
|
}
|
||||||
|
$targetFile = $targetDir . basename($_FILES['sequenceFile']['name']);
|
||||||
|
|
||||||
|
if (move_uploaded_file($_FILES['sequenceFile']['tmp_name'], $targetFile)) {
|
||||||
|
$uploadMessage = '<div class="alert alert-success mt-3">File uploaded successfully.</div>';
|
||||||
|
} else {
|
||||||
|
$uploadMessage = '<div class="alert alert-danger mt-3">Sorry, there was an error uploading your file.</div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$uploadMessage = '<div class="alert alert-danger mt-3">Invalid sequence ID for upload.</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!empty($sequenceId) && is_numeric($sequenceId)) {
|
||||||
|
$sequenceDetails = getSequenceDetails($sequenceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine badge class based on status
|
||||||
|
$statusClass = 'bg-secondary';
|
||||||
|
if (isset($sequenceDetails['status'])) {
|
||||||
|
switch ($sequenceDetails['status']) {
|
||||||
|
case 'Validated':
|
||||||
|
$statusClass = 'bg-success';
|
||||||
|
break;
|
||||||
|
case 'Validation Failed':
|
||||||
|
$statusClass = 'bg-danger';
|
||||||
|
break;
|
||||||
|
case 'Missing index.xml':
|
||||||
|
$statusClass = 'bg-warning text-dark';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Sequence Details - eCTD Submission Manager</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<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;500;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header class="header bg-primary text-white">
|
||||||
|
<div class="container d-flex justify-content-between align-items-center">
|
||||||
|
<h1 class="h4 mb-0">eCTD Submission Manager</h1>
|
||||||
|
<a href="index.php" class="btn btn-light">← Back to Dashboard</a>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="container mt-4">
|
||||||
|
<?php if ($sequenceDetails): ?>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h2 class="h5 mb-0">Sequence Details: <?php echo htmlspecialchars($sequenceDetails['id']); ?></h2>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p><strong>Product Name:</strong> <?php echo htmlspecialchars($sequenceDetails['productName']); ?></p>
|
||||||
|
<p><strong>Status:</strong> <span class="badge <?php echo $statusClass; ?>"><?php echo htmlspecialchars($sequenceDetails['status']); ?></span></p>
|
||||||
|
|
||||||
|
<?php if (!empty($sequenceDetails['validation_errors'])): ?>
|
||||||
|
<h3 class="h6 mt-4">Validation Report</h3>
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul class="mb-0">
|
||||||
|
<?php foreach ($sequenceDetails['validation_errors'] as $error): ?>
|
||||||
|
<li><?php echo htmlspecialchars($error); ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<h3 class="h6 mt-4">Files in Sequence</h3>
|
||||||
|
<?php if (!empty($sequenceDetails['files'])): ?>
|
||||||
|
<ul class="list-group">
|
||||||
|
<?php foreach ($sequenceDetails['files'] as $file): ?>
|
||||||
|
<li class="list-group-item"><?php echo htmlspecialchars($file); ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>No files found in this sequence.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<h3 class="h6 mt-4">index.xml Content</h3>
|
||||||
|
<?php if (!empty($sequenceDetails['xml_content'])): ?>
|
||||||
|
<pre class="bg-light p-3 rounded"><code><?php echo $sequenceDetails['xml_content']; ?></code></pre>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>No index.xml content to display.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<hr class="my-4">
|
||||||
|
|
||||||
|
<h3 class="h6 mt-4">Upload File to Sequence</h3>
|
||||||
|
<?php echo $uploadMessage; ?>
|
||||||
|
<form action="sequence.php?id=<?php echo htmlspecialchars($sequenceId); ?>" method="post" enctype="multipart/form-data">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="sequenceFile" class="form-label">Select file</label>
|
||||||
|
<input class="form-control" type="file" id="sequenceFile" name="sequenceFile" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Upload File</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<strong>Error:</strong> Invalid or missing sequence ID.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
29
validators/xml_validator.php
Normal file
29
validators/xml_validator.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
class XmlValidator {
|
||||||
|
public static function validate($xmlString) {
|
||||||
|
$errors = [];
|
||||||
|
$dom = new DOMDocument();
|
||||||
|
if (!@$dom->loadXML($xmlString)) {
|
||||||
|
$errors[] = "Failed to parse XML.";
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rootElement = $dom->documentElement;
|
||||||
|
if ($rootElement->tagName !== 'ectd:ectd') {
|
||||||
|
$errors[] = "Root element is not 'ectd:ectd'.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtdVersion = $dom->getElementsByTagName('dtd-version')->item(0);
|
||||||
|
if (!$dtdVersion || empty($dtdVersion->nodeValue)) {
|
||||||
|
$errors[] = "Required tag 'dtd-version' is missing or empty.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$submissionType = $dom->getElementsByTagName('submission-type')->item(0);
|
||||||
|
if (!$submissionType || empty($submissionType->nodeValue)) {
|
||||||
|
$errors[] = "Required tag 'submission-type' is missing or empty.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
x
Reference in New Issue
Block a user