From 01a63cbdaa4013e05be92385284efa72f306fa96 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 29 Dec 2025 07:28:15 +0000 Subject: [PATCH] 1.0 --- assets/css/style.css | 54 +++++++++++++++ auth.php | 10 +++ dashboard.php | 72 +++++++++++++++++++ db/config.php | 53 ++++++++++---- db/setup.php | 36 ++++++++++ index.php | 161 ++++--------------------------------------- login.php | 74 ++++++++++++++++++++ logout.php | 6 ++ register.php | 21 ++++++ templates/footer.php | 2 + templates/header.php | 10 +++ 11 files changed, 337 insertions(+), 162 deletions(-) create mode 100644 assets/css/style.css create mode 100644 auth.php create mode 100644 dashboard.php create mode 100644 db/setup.php create mode 100644 login.php create mode 100644 logout.php create mode 100644 register.php create mode 100644 templates/footer.php create mode 100644 templates/header.php diff --git a/assets/css/style.css b/assets/css/style.css new file mode 100644 index 0000000..67762fb --- /dev/null +++ b/assets/css/style.css @@ -0,0 +1,54 @@ +body { + font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif; + background-color: #1A1A1A; +} + +.bg-dark { + background-color: #1A1A1A !important; +} + +.bg-surface { + background-color: #2C2C2C !important; +} + +.text-light { + color: #EAEAEA !important; +} + +.text-primary { + color: #00BFFF !important; +} + +.btn-primary { + background-color: #00BFFF; + border-color: #00BFFF; +} + +.btn-primary:hover { + background-color: #009acd; + border-color: #009acd; +} + +.card { + border: none; + border-radius: 0.5rem; +} + +.form-control { + border-radius: 0.5rem; + border: 1px solid #444; +} + +.form-control:focus { + box-shadow: 0 0 0 0.25rem rgba(0, 191, 255, 0.25); + border-color: #00BFFF; +} + +.navbar-dark .navbar-nav .nav-link { + color: #EAEAEA; +} + +.navbar-dark .navbar-nav .nav-link:hover, +.navbar-dark .navbar-nav .nav-link.active { + color: #00BFFF; +} diff --git a/auth.php b/auth.php new file mode 100644 index 0000000..fb95ce4 --- /dev/null +++ b/auth.php @@ -0,0 +1,10 @@ + + + + + + +
+
+
+

Welcome, !

+

This is your central hub for managing your football team. From here you can manage players, schedules, and finances.

+
+
+ +
+
+
+

Manage Team

+

Add, edit, and view team members.

+ +
+
+
+
+

Upcoming Events

+

View upcoming training sessions and matches.

+ +
+
+
+ +
+ + + + diff --git a/db/config.php b/db/config.php index 4b9543f..5b4f8f1 100644 --- a/db/config.php +++ b/db/config.php @@ -1,17 +1,42 @@ getenv('DB_HOST') ?: '127.0.0.1', + 'port' => getenv('DB_PORT') ?: '3306', + 'name' => getenv('DB_NAME') ?: 'default_db', + 'user' => getenv('DB_USER') ?: 'default_user', + 'pass' => getenv('DB_PASS') ?: 'default_pass', + ]; + if (empty($config['name'])) die('DB_NAME is not set'); + if (empty($config['user'])) die('DB_USER is not set'); + return $config; +} function db() { - static $pdo; - if (!$pdo) { - $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } - return $pdo; -} + static $pdo; + if ($pdo) { + return $pdo; + } + try { + $c = get_db_config(); + $dsn = sprintf('mysql:host=%s;port=%d;dbname=%s;charset=utf8mb4', $c['host'], $c['port'], $c['name']); + $pdo = new PDO($dsn, $c['user'], $c['pass'], [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]); + return $pdo; + } catch (PDOException $e) { + error_log($e->getMessage()); + http_response_code(500); + die('Database connection failed. Check server logs.'); + } +} \ No newline at end of file diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..8f5a6c8 --- /dev/null +++ b/db/setup.php @@ -0,0 +1,36 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // Create users table + $sql = "CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + email VARCHAR(100) NOT NULL UNIQUE, + no_hp VARCHAR(20), + role ENUM('admin', 'player') NOT NULL DEFAULT 'player', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + )"; + $pdo->exec($sql); + + // Check if admin user exists + $stmt = $pdo->prepare("SELECT id FROM users WHERE username = ?"); + $stmt->execute(['admin']); + if ($stmt->fetchColumn() === false) { + // Insert a default admin user if it doesn't exist + $adminPassword = password_hash('admin123', PASSWORD_DEFAULT); + $adminEmail = 'admin@example.com'; + $adminStmt = $pdo->prepare("INSERT INTO users (username, password, email, role) VALUES (?, ?, ?, ?)"); + $adminStmt->execute(['admin', $adminPassword, $adminEmail, 'admin']); + echo "Default admin user created successfully.
"; + } + + echo "Database setup completed successfully!"; + +} catch (PDOException $e) { + die("Database setup failed: " . $e->getMessage()); +} diff --git a/index.php b/index.php index 7205f3d..eeddb32 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,15 @@ - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

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

-
-
- - - +if (session_status() == PHP_SESSION_NONE) { + session_start(); +} + +if (isset($_SESSION['user_id'])) { + // User is logged in, redirect to the dashboard + header('Location: dashboard.php'); +} else { + // User is not logged in, redirect to the login page + header('Location: login.php'); +} +exit(); \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..bbcfdc5 --- /dev/null +++ b/login.php @@ -0,0 +1,74 @@ +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']; + $_SESSION['role'] = $user['role']; + header('Location: dashboard.php'); + exit(); + } else { + $error = 'Invalid username or password.'; + } + } catch (PDOException $e) { + $error = 'Database error. Please try again later.'; + error_log($e->getMessage()); + } + } +} + +require_once 'templates/header.php'; +?> + + +
+
+
+
+
+

Team Manager

+

Login

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

Register

+

This feature is not yet implemented.

+ +
+
+
+
+
+ + + diff --git a/templates/footer.php b/templates/footer.php new file mode 100644 index 0000000..150f549 --- /dev/null +++ b/templates/footer.php @@ -0,0 +1,2 @@ + + diff --git a/templates/header.php b/templates/header.php new file mode 100644 index 0000000..75dec56 --- /dev/null +++ b/templates/header.php @@ -0,0 +1,10 @@ + + + + + + <?php echo htmlspecialchars(getenv('PROJECT_NAME') ?: 'Team Manager'); ?> + + + +