Compare commits

...

3 Commits

Author SHA1 Message Date
Flatlogic Bot
761c9a942b Mantis-v0.0.3 2026-01-15 17:29:08 +00:00
Flatlogic Bot
bb70c85b30 Mantis-v0.0.2 2026-01-15 17:23:02 +00:00
Flatlogic Bot
19a618c6e5 Mantis-v0.0.1 2026-01-15 17:13:40 +00:00
8 changed files with 417 additions and 106 deletions

86
add_bug.php Normal file
View File

@ -0,0 +1,86 @@
<?php
require_once 'db/config.php';
$title = $description = $steps_to_reproduce = '';
$test_case_id = null;
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['test_case_id'])) {
$test_case_id = (int)$_GET['test_case_id'];
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = trim($_POST['title'] ?? '');
$description = trim($_POST['description'] ?? '');
$steps_to_reproduce = trim($_POST['steps_to_reproduce'] ?? '');
$test_case_id = isset($_POST['test_case_id']) ? (int)$_POST['test_case_id'] : null;
if (empty($title)) {
$errors[] = 'Title is required.';
}
if (empty($errors)) {
try {
$pdo = db();
$sql = 'INSERT INTO bugs (title, description, steps_to_reproduce, test_case_id) VALUES (?, ?, ?, ?)';
$stmt = $pdo->prepare($sql);
$stmt->execute([$title, $description, $steps_to_reproduce, $test_case_id]);
header('Location: bugs.php');
exit;
} catch (PDOException $e) {
$errors[] = 'Database error: ' . $e->getMessage();
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add New Bug</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { background-color: #f8fafc; }
</style>
</head>
<body>
<div class="container py-5">
<h1 class="h3 mb-4">Add New Bug</h1>
<?php if (!empty($errors)): ?>
<div class="alert alert-danger">
<?php foreach ($errors as $error): ?>
<p class="mb-0"><?php echo $error; ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body">
<form action="add_bug.php" method="POST">
<?php if ($test_case_id): ?>
<input type="hidden" name="test_case_id" value="<?php echo $test_case_id; ">
<?php endif; ?>
<div class="mb-3">
<label for="title" class="form-label">Title</label>
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" rows="5"><?php echo htmlspecialchars($description); ?></textarea>
</div>
<div class="mb-3">
<label for="steps_to_reproduce" class="form-label">Steps to Reproduce</label>
<textarea class="form-control" id="steps_to_reproduce" name="steps_to_reproduce" rows="5"><?php echo htmlspecialchars($steps_to_reproduce); ?></textarea>
</div>
<div class="d-flex justify-content-end">
<a href="bugs.php" class="btn btn-secondary me-2">Cancel</a>
<button type="submit" class="btn btn-primary">Submit Bug</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>

86
add_test_case.php Normal file
View File

@ -0,0 +1,86 @@
<?php
require_once 'db/config.php';
$title = $description = $precondition = $steps_to_execute = $expected_result = '';
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = trim($_POST['title'] ?? '');
$description = trim($_POST['description'] ?? '');
$precondition = trim($_POST['precondition'] ?? '');
$steps_to_execute = trim($_POST['steps_to_execute'] ?? '');
$expected_result = trim($_POST['expected_result'] ?? '');
if (empty($title)) {
$errors[] = 'Title is required.';
}
if (empty($errors)) {
try {
$pdo = db();
$stmt = $pdo->prepare('INSERT INTO test_cases (title, description, precondition, steps_to_execute, expected_result) VALUES (?, ?, ?, ?, ?)');
$stmt->execute([$title, $description, $precondition, $steps_to_execute, $expected_result]);
header('Location: test_cases.php');
exit;
} catch (PDOException $e) {
$errors[] = 'Database error: ' . $e->getMessage();
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add New Test Case</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { background-color: #f8fafc; }
</style>
</head>
<body>
<div class="container py-5">
<h1 class="h3 mb-4">Add New Test Case</h1>
<?php if (!empty($errors)): ?>
<div class="alert alert-danger">
<?php foreach ($errors as $error): ?>
<p class="mb-0"><?php echo $error; ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="card">
<div class="card-body">
<form action="add_test_case.php" method="POST">
<div class="mb-3">
<label for="title" class="form-label">Title</label>
<input type="text" class="form-control" id="title" name="title" value="<?php echo htmlspecialchars($title); ?>" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" rows="3"><?php echo htmlspecialchars($description); ?></textarea>
</div>
<div class="mb-3">
<label for="precondition" class="form-label">Precondition</label>
<textarea class="form-control" id="precondition" name="precondition" rows="3"><?php echo htmlspecialchars($precondition); ?></textarea>
</div>
<div class="mb-3">
<label for="steps_to_execute" class="form-label">Steps to Execute</label>
<textarea class="form-control" id="steps_to_execute" name="steps_to_execute" rows="5"><?php echo htmlspecialchars($steps_to_execute); ?></textarea>
</div>
<div class="mb-3">
<label for="expected_result" class="form-label">Expected Result</label>
<textarea class="form-control" id="expected_result" name="expected_result" rows="3"><?php echo htmlspecialchars($expected_result); ?></textarea>
</div>
<div class="d-flex justify-content-end">
<a href="test_cases.php" class="btn btn-secondary me-2">Cancel</a>
<button type="submit" class="btn btn-primary">Submit Test Case</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

75
bugs.php Normal file
View File

@ -0,0 +1,75 @@
<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->query('SELECT * FROM bugs ORDER BY created_at DESC');
$bugs = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bug Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<style>
body { background-color: #f8fafc; }
.card { border: 1px solid #e2e8f0; }
</style>
</head>
<body>
<div class="container py-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3">Bug Dashboard</h1>
<a href="add_bug.php" class="btn btn-primary d-inline-flex align-items-center">
<i data-feather="plus" class="me-2"></i>Add New Bug
</a>
</div>
<div class="card">
<div class="card-body">
<?php if (empty($bugs)): ?>
<div class="text-center py-5">
<p class="mb-0">No bugs found.</p>
</div>
<?php else: ?>
<div class="table-responsive">
<table class="table table-hover">
<thead class="table-light">
<tr>
<th scope="col">Title</th>
<th scope="col">Status</th>
<th scope="col">Created At</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($bugs as $bug): ?>
<tr>
<td><?php echo htmlspecialchars($bug['title']); ?></td>
<td><span class="badge bg-secondary"><?php echo htmlspecialchars($bug['status']); ?></span></td>
<td><?php echo htmlspecialchars($bug['created_at']); ?></td>
<td>
<a href="#" class="btn btn-sm btn-outline-secondary d-inline-flex align-items-center">
<i data-feather="eye" class="me-2"></i>View
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<div class="text-center mt-4">
<a href="index.php">Back to Home</a>
</div>
</div>
<script>
feather.replace()
</script>
</body>
</html>

View File

@ -5,6 +5,8 @@ define('DB_NAME', 'app_37487');
define('DB_USER', 'app_37487');
define('DB_PASS', '693524f4-8c9f-4c2d-8319-33438c0007b8');
require_once __DIR__ . '/database.php';
function db() {
static $pdo;
if (!$pdo) {
@ -15,3 +17,5 @@ function db() {
}
return $pdo;
}
create_schema();

57
db/database.php Normal file
View File

@ -0,0 +1,57 @@
<?php
function create_schema() {
try {
$pdo = db();
$sql = "
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('Admin', 'Tester', 'Developer') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS test_cases (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
precondition TEXT,
steps_to_execute TEXT,
expected_result TEXT,
status ENUM('New', 'Passed', 'Failed', 'Blocked') NOT NULL DEFAULT 'New',
feature_area VARCHAR(100),
created_by INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (created_by) REFERENCES users(id)
);
CREATE TABLE IF NOT EXISTS bugs (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
steps_to_reproduce TEXT,
status ENUM('New', 'Testing/Tested', 'Verified', 'Closed') NOT NULL DEFAULT 'New',
test_case_id INT,
created_by INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (test_case_id) REFERENCES test_cases(id),
FOREIGN KEY (created_by) REFERENCES users(id)
);
CREATE TABLE IF NOT EXISTS comments (
id INT AUTO_INCREMENT PRIMARY KEY,
bug_id INT,
test_case_id INT,
user_id INT NOT NULL,
comment TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (bug_id) REFERENCES bugs(id),
FOREIGN KEY (test_case_id) REFERENCES test_cases(id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
";
$pdo->exec($sql);
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}
}

119
index.php
View File

@ -12,10 +12,10 @@ $now = date('Y-m-d H:i:s');
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<title>Bug Tracker</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'A bug and test case tracking application.';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
@ -32,119 +32,26 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<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;
font-family: 'Inter', sans-serif;
background-color: #f8fafc;
}
</style>
</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>
</div>
<main class="container py-5 text-center">
<h1 class="display-4">Welcome to Your Bug Tracker</h1>
<p class="lead">A simple application to track bugs and test cases.</p>
<a href="bugs.php" class="btn btn-primary btn-lg mt-3">Go to Bug Dashboard</a>
<a href="test_cases.php" class="btn btn-secondary btn-lg mt-3">Go to Test Case Dashboard</a>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
<footer class="text-center mt-5">
<p class="text-muted">Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</footer>
</body>
</html>
</html>

96
test_cases.php Normal file
View File

@ -0,0 +1,96 @@
<?php
require_once 'db/config.php';
$pdo = db();
$stmt = $pdo->query('SELECT * FROM test_cases ORDER BY created_at DESC');
$test_cases = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Case Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<style>
body { background-color: #f8fafc; }
.card { border: 1px solid #e2e8f0; }
</style>
</head>
<body>
<div class="container py-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3">Test Case Dashboard</h1>
<a href="add_test_case.php" class="btn btn-primary d-inline-flex align-items-center">
<i data-feather="plus" class="me-2"></i>Add New Test Case
</a>
</div>
<div class="card">
<div class="card-body">
<?php if (empty($test_cases)): ?>
<div class="text-center py-5">
<p class="mb-0">No test cases found.</p>
</div>
<?php else: ?>
<div class="table-responsive">
<table class="table table-hover">
<thead class="table-light">
<tr>
<th scope="col">Title</th>
<th scope="col">Status</th>
<th scope="col">Created At</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($test_cases as $test_case): ?>
<tr>
<td><?php echo htmlspecialchars($test_case['title']); ?></td>
<td>
<?php
$status_color = 'secondary';
switch ($test_case['status']) {
case 'Passed':
$status_color = 'success';
break;
case 'Failed':
$status_color = 'danger';
break;
case 'Blocked':
$status_color = 'warning';
break;
}
?>
<span class="badge bg-<?php echo $status_color; ?>"><?php echo htmlspecialchars($test_case['status']); ?></span>
</td>
<td><?php echo htmlspecialchars($test_case['created_at']); ?></td>
<td>
<a href="#" class="btn btn-sm btn-outline-secondary d-inline-flex align-items-center me-2">
<i data-feather="eye" class="me-1"></i>View
</a>
<?php if ($test_case['status'] === 'Failed'): ?>
<a href="add_bug.php?test_case_id=<?php echo $test_case['id']; ?>" class="btn btn-sm btn-danger d-inline-flex align-items-center me-2">
<i data-feather="plus" class="me-1"></i>Add Bug
</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<div class="text-center mt-4">
<a href="index.php">Back to Home</a>
</div>
</div>
<script>
feather.replace()
</script>
</body>
</html>