diff --git a/auth.php b/auth.php new file mode 100644 index 0000000..0cd150e --- /dev/null +++ b/auth.php @@ -0,0 +1,7 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + ]); + $pdo_admin->exec("CREATE DATABASE IF NOT EXISTS `" . DB_NAME . "`;"); + echo "Database '" . DB_NAME . "' created or already exists.\n"; + + // Now connect to the specific database to run migrations + $pdo = db(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $migrationsDir = __DIR__ . '/migrations'; + $files = glob($migrationsDir . '/*.sql'); + sort($files); + + foreach ($files as $file) { + echo "Running migration: " . basename($file) . "\n"; + $sql = file_get_contents($file); + $pdo->exec($sql); + echo "Success.\n"; + } + + echo "All migrations completed.\n"; + +} catch (PDOException $e) { + die("Database migration failed: " . $e->getMessage()); +} \ No newline at end of file diff --git a/db/migrations/001_create_users_table.sql b/db/migrations/001_create_users_table.sql new file mode 100644 index 0000000..599948d --- /dev/null +++ b/db/migrations/001_create_users_table.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + email VARCHAR(255) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + role ENUM('admin', 'client') NOT NULL DEFAULT 'client', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- Add a default admin user for initial access +INSERT INTO users (name, email, password, role) +SELECT 'Admin', 'admin@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'admin' -- password is 'password' +WHERE NOT EXISTS (SELECT 1 FROM users WHERE email = 'admin@example.com'); diff --git a/index.php b/index.php index 8c1db52..fefd238 100644 --- a/index.php +++ b/index.php @@ -1,151 +1,67 @@ - + - New Style - - - - - - - - - - - - - - - - - - + Dashboard - Gestão Imobiliária + -
+ + +
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-

Contact Us

+
+

Bem-vindo ao seu Dashboard

+

Esta é a sua área privada. O seu perfil é: .

+

A partir daqui, poderá gerir imóveis, clientes e visitas.

+
+

Runtime: PHP — UTC

+

Contactar Suporte

+
-