diff --git a/auth/login_handler.php b/auth/login_handler.php new file mode 100644 index 0000000..9167766 --- /dev/null +++ b/auth/login_handler.php @@ -0,0 +1,37 @@ +prepare("SELECT id, password, role FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + // Password is correct, start session + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_role'] = $user['role']; + + header('Location: /dashboard.php'); + exit; + } else { + header('Location: /login.php?error=auth_failed'); + exit; + } + + } catch (PDOException $e) { + header('Location: /login.php?error=db_error'); + exit; + } +} diff --git a/auth/register_handler.php b/auth/register_handler.php new file mode 100644 index 0000000..7ae50c1 --- /dev/null +++ b/auth/register_handler.php @@ -0,0 +1,37 @@ +prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + header('Location: /register.php?error=user_exists'); + exit; + } + + // Insert new user + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + $stmt = $pdo->prepare("INSERT INTO users (email, password, role) VALUES (?, ?, ?)"); + $stmt->execute([$email, $hashed_password, 'FREE_USER']); + + header('Location: /login.php?success=registered'); + exit; + + } catch (PDOException $e) { + // In a real app, log this error. + header('Location: /register.php?error=db_error'); + exit; + } +} diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..d9effe1 --- /dev/null +++ b/dashboard.php @@ -0,0 +1,28 @@ + + +
+

Welcome to Your Dashboard

+

Your role:

+ +
+

Your CVs

+

You don't have any CVs yet.

+ Create a New CV +
+ + Logout +
+ + diff --git a/db/create_db.php b/db/create_db.php new file mode 100644 index 0000000..7989563 --- /dev/null +++ b/db/create_db.php @@ -0,0 +1,18 @@ + PDO::ERRMODE_EXCEPTION, + ]); + + // Create the database if it doesn't exist + $pdo->exec("CREATE DATABASE IF NOT EXISTS `" . DB_NAME . "`"); + + echo "Database '" . DB_NAME . "' created successfully or already exists.\n"; + +} catch (PDOException $e) { + die("Database creation failed: " . $e->getMessage() . "\n"); +} + diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..7af8c16 --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,12 @@ +exec($sql); + echo "Database migration successful!\n"; +} catch (PDOException $e) { + die("Database migration failed: " . $e->getMessage() . "\n"); +} + diff --git a/db/migrations/001_initial_schema.sql b/db/migrations/001_initial_schema.sql new file mode 100644 index 0000000..37853e7 --- /dev/null +++ b/db/migrations/001_initial_schema.sql @@ -0,0 +1,43 @@ +-- Initial Schema for MagiCV + +-- Organizations table for multitenancy +CREATE TABLE IF NOT EXISTS `organizations` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Users table with roles +CREATE TABLE IF NOT EXISTS `users` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `organization_id` INT NULL, + `email` VARCHAR(255) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `role` ENUM('GUEST', 'FREE_USER', 'PRO_USER', 'SUPER_ADMIN') NOT NULL DEFAULT 'FREE_USER', + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Templates for CVs +CREATE TABLE IF NOT EXISTS `templates` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `description` TEXT, + `is_pro` BOOLEAN NOT NULL DEFAULT FALSE, + `thumbnail_url` VARCHAR(255), + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- CVs table to store user resume data +CREATE TABLE IF NOT EXISTS `cvs` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `user_id` INT NOT NULL, + `template_id` INT, + `title` VARCHAR(255) NOT NULL, + `cv_data` JSON, + `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, + FOREIGN KEY (`template_id`) REFERENCES `templates`(`id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..b5a6a90 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..2b5aab6 --- /dev/null +++ b/includes/header.php @@ -0,0 +1,21 @@ + + + + + + MagiCV + + + +
+ +
+
diff --git a/index.php b/index.php index e13ae95..7d62711 100644 --- a/index.php +++ b/index.php @@ -1,131 +1,46 @@ - -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); -?> - - - - - - New Style - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

Flatlogic AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

+
+

Create a CV that gets you hired

+

MagiCV helps you build a professional, polished resume in minutes. Impress recruiters and land your dream job.

+ Create Your CV Now +
+ +
+

Choose Your Template

+

Stunning, professional templates for every industry. More coming soon!

+ -
- - - + + +
+

Features

+
+
+

Easy to Use

+

Our intuitive editor makes it simple to create and update your CV.

+
+
+

Professional Templates

+

Choose from a library of beautifully designed templates.

+
+
+

PDF Export

+

Download your CV as a high-quality PDF, ready to send.

+
+
+
+ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..4c79c15 --- /dev/null +++ b/login.php @@ -0,0 +1,29 @@ + + +
+

Login to Your Account

+ +

Invalid email or password.

+ + +

Registration successful! Please login.

+ +
+
+ + +
+
+ + +
+ +
+

Don't have an account? Register here.

+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..91d13cc --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ + + +
+

Create Your Account

+ +

+ +

+ +
+
+ + +
+
+ + +
+ +
+

Already have an account? Login here.

+
+ +