Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39839fb76f | ||
|
|
898c8cc6df | ||
|
|
5dbc3003eb | ||
|
|
b3efbfaaef | ||
|
|
df74e9b296 | ||
|
|
a0db2eeb84 | ||
|
|
e95b5c1b6e | ||
|
|
27e631c514 | ||
|
|
5eac55563f | ||
|
|
ab93e047c8 |
71
add_scene.php
Normal file
71
add_scene.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'User not authenticated']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$request_body = file_get_contents('php://input');
|
||||||
|
$data = json_decode($request_body, true);
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Invalid request']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$project_id = filter_var($data['project_id'] ?? null, FILTER_VALIDATE_INT);
|
||||||
|
$description = trim($data['description'] ?? '');
|
||||||
|
$duration = filter_var($data['duration'] ?? null, FILTER_VALIDATE_INT);
|
||||||
|
$shot_type = trim($data['shot_type'] ?? '');
|
||||||
|
|
||||||
|
if (!$project_id || empty($description) || !$duration || empty($shot_type)) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Invalid input. Required fields: project_id, description, duration, shot_type']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Verify project ownership and status
|
||||||
|
$stmt = $pdo->prepare("SELECT status FROM projects WHERE id = ? AND user_id = ?");
|
||||||
|
$stmt->execute([$project_id, $_SESSION['user_id']]);
|
||||||
|
$project = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$project) {
|
||||||
|
http_response_code(404);
|
||||||
|
echo json_encode(['error' => 'Project not found or you do not have permission to access it.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($project['status'] !== 'draft') {
|
||||||
|
http_response_code(403);
|
||||||
|
echo json_encode(['error' => 'Project is not in draft status, scenes cannot be added.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert new scene
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO scenes (project_id, user_id, description, duration, shot_type) VALUES (?, ?, ?, ?, ?)");
|
||||||
|
$stmt->execute([$project_id, $_SESSION['user_id'], $description, $duration, $shot_type]);
|
||||||
|
|
||||||
|
$new_scene_id = $pdo->lastInsertId();
|
||||||
|
|
||||||
|
// Fetch the newly created scene
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM scenes WHERE id = ?");
|
||||||
|
$stmt->execute([$new_scene_id]);
|
||||||
|
$scene = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
http_response_code(201);
|
||||||
|
echo json_encode($scene);
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
// error_log("Database error: " . $e->getMessage()); // It's good practice to log the actual error
|
||||||
|
echo json_encode(['error' => 'Database error.']);
|
||||||
|
}
|
||||||
39
assets/css/custom.css
Normal file
39
assets/css/custom.css
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
:root {
|
||||||
|
--primary-color: #4F46E5;
|
||||||
|
--light-gray: #f8f9fa;
|
||||||
|
--white: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: var(--light-gray);
|
||||||
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border: none;
|
||||||
|
border-radius: .75rem;
|
||||||
|
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
background-color: var(--white);
|
||||||
|
border-bottom: none;
|
||||||
|
padding: 1.5rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
padding: .75rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #4338CA;
|
||||||
|
border-color: #4338CA;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus {
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25);
|
||||||
|
}
|
||||||
BIN
assets/pasted-20260101-095324-285a9cb6.png
Normal file
BIN
assets/pasted-20260101-095324-285a9cb6.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
BIN
assets/pasted-20260101-095442-40a3627d.png
Normal file
BIN
assets/pasted-20260101-095442-40a3627d.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
52
create_project.php
Normal file
52
create_project.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'Authentication required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
|
||||||
|
http_response_code(405);
|
||||||
|
echo json_encode(['error' => 'Method Not Allowed']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$input = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
|
$title = $input['title'] ?? null;
|
||||||
|
$story_text = $input['story_text'] ?? null;
|
||||||
|
$style = $input['style'] ?? null;
|
||||||
|
$target_duration = isset($input['target_duration']) ? filter_var($input['target_duration'], FILTER_VALIDATE_INT) : null;
|
||||||
|
|
||||||
|
if (empty($title)) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Title is a required field.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare(
|
||||||
|
"INSERT INTO projects (user_id, title, story_text, style, target_duration, status) VALUES (?, ?, ?, ?, ?, 'draft')"
|
||||||
|
);
|
||||||
|
$stmt->execute([$_SESSION['user_id'], $title, $story_text, $style, $target_duration]);
|
||||||
|
|
||||||
|
$projectId = $pdo->lastInsertId();
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM projects WHERE id = ? AND user_id = ?");
|
||||||
|
$stmt->execute([$projectId, $_SESSION['user_id']]);
|
||||||
|
$project = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
http_response_code(201);
|
||||||
|
echo json_encode($project);
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
error_log('Project creation failed: ' . $e->getMessage());
|
||||||
|
echo json_encode(['error' => 'An internal server error occurred while creating the project.']);
|
||||||
|
}
|
||||||
29
dashboard.php
Normal file
29
dashboard.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
require "db/config.php";
|
||||||
|
|
||||||
|
$userId = $_SESSION['user_id'] ?? null;
|
||||||
|
|
||||||
|
if (!$userId) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(["error" => "unauthorized"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = db()->prepare("
|
||||||
|
SELECT id, title, status, created_at, updated_at, final_video_url
|
||||||
|
FROM projects
|
||||||
|
WHERE user_id = ?
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
");
|
||||||
|
$stmt->execute([$userId]);
|
||||||
|
|
||||||
|
echo json_encode($stmt->fetchAll());
|
||||||
|
exit;
|
||||||
|
?>
|
||||||
58
db/migrate.php
Normal file
58
db/migrate.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$sql = "
|
||||||
|
CREATE TABLE IF NOT EXISTS `users` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`email` VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
`password` VARCHAR(255) NOT NULL,
|
||||||
|
`planType` ENUM('basic', 'pro') DEFAULT 'basic',
|
||||||
|
`creditsFastRemaining` INT DEFAULT 10,
|
||||||
|
`creditsQualityRemaining` INT DEFAULT 5,
|
||||||
|
`monthlyResetDate` DATE,
|
||||||
|
`role` ENUM('user', 'admin') DEFAULT 'user',
|
||||||
|
`createdAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
";
|
||||||
|
$pdo->exec($sql);
|
||||||
|
|
||||||
|
$sql = "
|
||||||
|
CREATE TABLE IF NOT EXISTS `projects` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`user_id` INT NOT NULL,
|
||||||
|
`title` VARCHAR(255) NOT NULL,
|
||||||
|
`story_text` TEXT,
|
||||||
|
`style` VARCHAR(100),
|
||||||
|
`target_duration` INT,
|
||||||
|
`status` ENUM('draft', 'scripted', 'rendering', 'completed', 'failed') DEFAULT 'draft',
|
||||||
|
`final_video_url` VARCHAR(255) NULL,
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
";
|
||||||
|
$pdo->exec($sql);
|
||||||
|
|
||||||
|
$sql = "
|
||||||
|
CREATE TABLE IF NOT EXISTS `scenes` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`project_id` INT NOT NULL,
|
||||||
|
`user_id` INT NOT NULL,
|
||||||
|
`scene_number` INT NULL,
|
||||||
|
`description` TEXT,
|
||||||
|
`duration` INT,
|
||||||
|
`shot_type` VARCHAR(100),
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
";
|
||||||
|
$pdo->exec($sql);
|
||||||
|
|
||||||
|
echo "Database migration completed successfully." . PHP_EOL;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Database migration failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
68
delete_project.php
Normal file
68
delete_project.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'User not authenticated']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$project_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
|
||||||
|
if (!$project_id) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Project ID is required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
http_response_code(405);
|
||||||
|
echo json_encode(['error' => 'POST method required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Begin a transaction
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
|
||||||
|
// Verify project ownership
|
||||||
|
$stmt = $pdo->prepare("SELECT id FROM projects WHERE id = ? AND user_id = ?");
|
||||||
|
$stmt->execute([$project_id, $_SESSION['user_id']]);
|
||||||
|
$project = $stmt->fetch();
|
||||||
|
|
||||||
|
if (!$project) {
|
||||||
|
http_response_code(404);
|
||||||
|
$pdo->rollBack();
|
||||||
|
echo json_encode(['error' => 'Project not found or permission denied.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete associated scenes first to maintain integrity
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM scenes WHERE project_id = ?");
|
||||||
|
$stmt->execute([$project_id]);
|
||||||
|
|
||||||
|
// Now, delete the project
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM projects WHERE id = ?");
|
||||||
|
$stmt->execute([$project_id]);
|
||||||
|
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
$pdo->commit();
|
||||||
|
echo json_encode(['success' => 'Project and all its scenes were deleted successfully.']);
|
||||||
|
} else {
|
||||||
|
$pdo->rollBack();
|
||||||
|
http_response_code(500); // Should not happen if ownership check passed
|
||||||
|
echo json_encode(['error' => 'Failed to delete project.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
if ($pdo->inTransaction()) {
|
||||||
|
$pdo->rollBack();
|
||||||
|
}
|
||||||
|
http_response_code(500);
|
||||||
|
// error_log("Database error: " . $e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Database error during project deletion.']);
|
||||||
|
}
|
||||||
66
delete_scene.php
Normal file
66
delete_scene.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'User not authenticated']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$scene_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
|
||||||
|
if (!$scene_id) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Scene ID is required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
http_response_code(405);
|
||||||
|
echo json_encode(['error' => 'POST method required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Fetch scene info to get project_id and verify ownership/status
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT s.project_id, p.status as project_status
|
||||||
|
FROM scenes s
|
||||||
|
JOIN projects p ON s.project_id = p.id
|
||||||
|
WHERE s.id = ? AND s.user_id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$scene_id, $_SESSION['user_id']]);
|
||||||
|
$scene = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$scene) {
|
||||||
|
http_response_code(404);
|
||||||
|
echo json_encode(['error' => 'Scene not found or permission denied.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($scene['project_status'] !== 'draft') {
|
||||||
|
http_response_code(403);
|
||||||
|
echo json_encode(['error' => 'Project is not in draft status; scene cannot be deleted.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the scene
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM scenes WHERE id = ?");
|
||||||
|
$stmt->execute([$scene_id]);
|
||||||
|
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
echo json_encode(['success' => 'Scene deleted successfully.']);
|
||||||
|
} else {
|
||||||
|
http_response_code(500); // This case might indicate an issue if the check passed but delete failed
|
||||||
|
echo json_encode(['error' => 'Failed to delete scene.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
// error_log("Database error: " . $e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Database error.']);
|
||||||
|
}
|
||||||
81
edit_project.php
Normal file
81
edit_project.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'User not authenticated']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$project_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
|
||||||
|
if (!$project_id) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Project ID is required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
http_response_code(405);
|
||||||
|
echo json_encode(['error' => 'POST method required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$request_body = file_get_contents('php://input');
|
||||||
|
$data = json_decode($request_body, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Invalid JSON input.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Verify project ownership and status
|
||||||
|
$stmt = $pdo->prepare("SELECT status FROM projects WHERE id = ? AND user_id = ?");
|
||||||
|
$stmt->execute([$project_id, $_SESSION['user_id']]);
|
||||||
|
$project = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$project) {
|
||||||
|
http_response_code(404);
|
||||||
|
echo json_encode(['error' => 'Project not found or permission denied.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($project['status'] !== 'draft') {
|
||||||
|
http_response_code(403);
|
||||||
|
echo json_encode(['error' => 'Project is not in draft status and cannot be edited.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get new data from request body
|
||||||
|
$title = trim($data['title'] ?? '');
|
||||||
|
$story_text = trim($data['story_text'] ?? '');
|
||||||
|
$style = trim($data['style'] ?? '');
|
||||||
|
$target_duration = filter_var($data['target_duration'] ?? null, FILTER_VALIDATE_INT, ['options' => ['default' => 0]]);
|
||||||
|
|
||||||
|
if (empty($title)) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Title is required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the project
|
||||||
|
$stmt = $pdo->prepare("UPDATE projects SET title = ?, story_text = ?, style = ?, target_duration = ? WHERE id = ?");
|
||||||
|
$stmt->execute([$title, $story_text, $style, $target_duration, $project_id]);
|
||||||
|
|
||||||
|
// Fetch and return the updated project
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM projects WHERE id = ?");
|
||||||
|
$stmt->execute([$project_id]);
|
||||||
|
$updated_project = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
echo json_encode($updated_project);
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
// error_log("Database error: " . $e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Database error.']);
|
||||||
|
}
|
||||||
87
edit_scene.php
Normal file
87
edit_scene.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'User not authenticated']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
// The scene ID must be passed as a URL parameter
|
||||||
|
$scene_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
|
||||||
|
if (!$scene_id) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Scene ID is required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
http_response_code(405); // Method Not Allowed
|
||||||
|
echo json_encode(['error' => 'POST method required.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$request_body = file_get_contents('php://input');
|
||||||
|
$data = json_decode($request_body, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Invalid JSON input.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Fetch scene and project status to verify ownership and draft status
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT s.project_id, p.status as project_status
|
||||||
|
FROM scenes s
|
||||||
|
JOIN projects p ON s.project_id = p.id
|
||||||
|
WHERE s.id = ? AND s.user_id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$scene_id, $_SESSION['user_id']]);
|
||||||
|
$scene_check = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$scene_check) {
|
||||||
|
http_response_code(404);
|
||||||
|
echo json_encode(['error' => 'Scene not found or permission denied.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($scene_check['project_status'] !== 'draft') {
|
||||||
|
http_response_code(403);
|
||||||
|
echo json_encode(['error' => 'Project is not in draft status; scene cannot be edited.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get new data from request body
|
||||||
|
$description = trim($data['description'] ?? '');
|
||||||
|
$duration = filter_var($data['duration'] ?? null, FILTER_VALIDATE_INT);
|
||||||
|
$shot_type = trim($data['shot_type'] ?? '');
|
||||||
|
|
||||||
|
// Basic validation
|
||||||
|
if (empty($description) || !$duration || empty($shot_type)) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Invalid input. All fields are required: description, duration, shot_type']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the scene
|
||||||
|
$stmt = $pdo->prepare("UPDATE scenes SET description = ?, duration = ?, shot_type = ? WHERE id = ?");
|
||||||
|
$stmt->execute([$description, $duration, $shot_type, $scene_id]);
|
||||||
|
|
||||||
|
// Fetch and return the updated scene
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM scenes WHERE id = ?");
|
||||||
|
$stmt->execute([$scene_id]);
|
||||||
|
$updated_scene = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
echo json_encode($updated_scene);
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
// error_log("Database error: " . $e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Database error.']);
|
||||||
|
}
|
||||||
198
index.php
198
index.php
@ -1,150 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
session_start();
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
if (isset($_SESSION['user_id'])) {
|
||||||
@date_default_timezone_set('UTC');
|
header('Location: dashboard.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read project preview data from environment
|
||||||
|
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'The backend for an AI Cinema Engine.';
|
||||||
|
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
?>
|
||||||
<!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>
|
<title>Welcome to AI Cinema Engine</title>
|
||||||
<?php
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
// Read project preview data from environment
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
<style>
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
body {
|
||||||
?>
|
background-color: #f8f9fa;
|
||||||
<?php if ($projectDescription): ?>
|
}
|
||||||
<!-- Meta description -->
|
.hero {
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
background: linear-gradient(to right, #4F46E5, #2563EB);
|
||||||
<!-- Open Graph meta tags -->
|
color: white;
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
padding: 8rem 0;
|
||||||
<!-- Twitter meta tags -->
|
text-align: center;
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
}
|
||||||
<?php endif; ?>
|
</style>
|
||||||
<?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>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
|
||||||
<div class="card">
|
<div class="hero">
|
||||||
<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">
|
<h1 class="display-4">AI Cinema Engine</h1>
|
||||||
<span class="sr-only">Loading…</span>
|
<p class="lead"><?= htmlspecialchars($projectDescription) ?></p>
|
||||||
</div>
|
<a href="register.php" class="btn btn-light btn-lg mx-2">Get Started</a>
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
<a href="login.php" class="btn btn-outline-light btn-lg mx-2">Login</a>
|
||||||
<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>
|
</div>
|
||||||
<footer>
|
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<div class="container mt-5">
|
||||||
</footer>
|
<div class="row">
|
||||||
|
<div class="col-md-4 text-center">
|
||||||
|
<h3>Feature 1</h3>
|
||||||
|
<p>Describe a core feature of your service here.</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 text-center">
|
||||||
|
<h3>Feature 2</h3>
|
||||||
|
<p>Describe another great benefit of using your application.</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 text-center">
|
||||||
|
<h3>Feature 3</h3>
|
||||||
|
<p>Highlight a unique selling proposition or technology.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="text-center mt-5 py-3 bg-light">
|
||||||
|
<p>© <?php echo date('Y'); ?> AI Cinema Engine. All Rights Reserved.</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
93
login.php
Normal file
93
login.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: dashboard.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$errors[] = 'Invalid email format.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare('SELECT * FROM users WHERE email = ?');
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
$user = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($user && password_verify($password, $user['password'])) {
|
||||||
|
$_SESSION['user_id'] = $user['id'];
|
||||||
|
$_SESSION['user_email'] = $user['email'];
|
||||||
|
header('Location: dashboard.php');
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$errors[] = 'Invalid email or password.';
|
||||||
|
}
|
||||||
|
} 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>Login - AI Cinema Engine</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 (!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; ?>
|
||||||
|
<form action="login.php" method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" 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>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<a href="register.php">Don't have an account? Register</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</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: index.php');
|
||||||
|
exit;
|
||||||
114
register.php
Normal file
114
register.php
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
require_once __DIR__ . '/db/config.php';
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (isset($_SESSION['user_id'])) {
|
||||||
|
header('Location: dashboard.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = [];
|
||||||
|
$success = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$email = trim($_POST['email']);
|
||||||
|
$password = $_POST['password'];
|
||||||
|
$password_confirm = $_POST['password_confirm'];
|
||||||
|
|
||||||
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$errors[] = 'Invalid email format.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($password) < 8) {
|
||||||
|
$errors[] = 'Password must be at least 8 characters long.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($password !== $password_confirm) {
|
||||||
|
$errors[] = 'Passwords do not match.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors)) {
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare('SELECT id FROM users WHERE email = ?');
|
||||||
|
$stmt->execute([$email]);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$errors[] = 'Email already registered.';
|
||||||
|
} else {
|
||||||
|
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
$stmt = $pdo->prepare('INSERT INTO users (email, password) VALUES (?, ?)');
|
||||||
|
if ($stmt->execute([$email, $hashed_password])) {
|
||||||
|
$success = 'Registration successful! You can now <a href="login.php">login</a>.';
|
||||||
|
} else {
|
||||||
|
$errors[] = 'Failed to register user. Please try again.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} 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>Register - AI Cinema Engine</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 (!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; ?>
|
||||||
|
<?php if ($success): ?>
|
||||||
|
<div class="alert alert-success">
|
||||||
|
<p class="mb-0"><?php echo $success; ?></p>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<form action="register.php" method="POST">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email address</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" 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="password_confirm" class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" class="form-control" id="password_confirm" name="password_confirm" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Register</button>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<a href="login.php">Already have an account? Login</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
40
view_project.php
Normal file
40
view_project.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'Unauthorized']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$project_id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
|
||||||
|
if (!$project_id) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Invalid project ID']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM projects WHERE id = ? AND user_id = ?");
|
||||||
|
$stmt->execute([$project_id, $_SESSION['user_id']]);
|
||||||
|
$project = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$project) {
|
||||||
|
http_response_code(404);
|
||||||
|
echo json_encode(['error' => 'Project not found']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scene_stmt = $pdo->prepare("SELECT * FROM scenes WHERE project_id = ? ORDER BY scene_number ASC");
|
||||||
|
$scene_stmt->execute([$project_id]);
|
||||||
|
$scenes = $scene_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$project['scenes'] = $scenes;
|
||||||
|
|
||||||
|
echo json_encode($project);
|
||||||
|
exit;
|
||||||
|
?>
|
||||||
Loading…
x
Reference in New Issue
Block a user